Critical density for the stability of a 2D magnet array