The previous answers are correct only in the limit for a sparse array, where the elements are spaced at greater than a wavelength apart. N is the "array gain" (for an un-tapered array) which is not the same thing as the "gain" of the array. Array gain is the improvement in SNR from the array, caused by the fact that the signal is added coherently while the noise is added non-coherently. The directivity of a planar array is the product of N and the directivity of an element only in the limit as element spacing becomes much larger than lambda. The general calculation for a planar array is more complicated. See Van Trees, "Optimum Array Processing" section 4.1.1.2.
Let us be clear on some definitions, referencing IEEE Std 145-2013, "IEEE Standard for Definitions of Terms for Antennas" and D.K. Cheng, "Field and Wave Electromagnetics". "Array gain" is actually not a sanctioned term, but is nonetheless often used in practice. "Directivity" is always greater than "gain" by a factor called "radiation efficiency." "Gain" is always in turn greater than "realized gain" by an "impedance mismatch" factor. To make matters even more confusing, in the past "gain" was often used synonymously with "directivity." The terms "power gain" and "directive gain" are both deprecated by IEEE.
However, to answer your specific question, the ratio of effective aperture to directivity is a universal constant, $\frac{\lambda^2}{4\pi}$. Effective aperture is also always less than or equal to the physical aperture, which in this case is $N\times dy\times dx$, where dy and dx are the spacing between elements in the x and y dimension. Thus, $A_e= N\times dx\times dy\times \eta$, where $\eta$ is a factor called the "illumination efficiency" that accounts for tapering of the array and spacing of the array. In the case of a sparse array, where element spacing $>\lambda$, $\eta$ is reduced because the array is not uniformly illuminated.
There is a physically intuitive reason for this relationship; essentially there are a limited number of photons per unit area to be captured by the individual antennas. Placing two high gain antennas very close to each other (less than a wavelength) does not buy twice the gain, for example. This is why the physical aperture size must be taken into account.
Let's assume a 16 x 16 un-tapered standard rectangular array (which means that elements are spaced at $\lambda \over 2$.) The array gain is $10log_{10}(N) = 10log_{10}(256) = 24.1$dB. If the array were tapered, this value would go down. The directivity, assuming isotropic elements, is 25.9dBi Van Trees. Now assume elements with 9.0dBi directivity. The directivity is not 33.1dBi, but rather is only 29.2dBi.[4] The reason for this is that the the effective aperture of the individual elements limits their directivity. So,
$D = A_e \times \frac{4\pi}{\lambda^2} = N \times dx \times dy \times \eta \times \frac{4\pi}{\lambda^2} = N \times \frac{\lambda}{2} \times \frac{\lambda}{2} \times \frac{4\pi}{\lambda^2} = N\pi$.
Note, in this case $\eta = 1$ because the array is un-tapered. Why the slight difference from $10log_{10}(N\pi)=$ 29.05 dBi? The elements around the edge of the array aren't as limited in their effective aperture as are the majority of elements.
Now let's move the array elements to $\lambda$ spacing. From the above formula, we expect the directivity to peak at $D = A_e \times \frac{4\pi}{\lambda^2} = N \times dx \times dy \times \eta \times \frac{4\pi}{\lambda^2} = N \times \lambda \times \lambda \times \frac{4\pi}{\lambda^2} = 4N\pi$. The actual result is 34.6380 dBi, just shy of the ideal 35.0745 dBi we expected.[4]. Why the difference from the ideal? If the spacing in the x and y dimensions is $\lambda$, then the spacing along the diagonals is $\lambda \sqrt{2}$, thus creating tiny regions in the overall array where photons are missed, leading to $\eta < 1$.
Now go to $10 \lambda$ spacing. The result now should converge to N times the element gain, or $10log_{10}(N)$ + 9 dBi = 33.1 dBi. The actual result is in fact, 33.1 dBi.[4]
[4]: MATLAB Phased Array System Toolbox, https://www.mathworks.com/products/phased-array.html