include Math
W = 20000
B = 80
n = gets.to_i

blocks = {}
points = []
min_d = Float::INFINITY
min_d2 = 0
x0, y0 = 10*W, 10*W

n.times{|point_idx|
	x, y = gets.split.map(&:to_i)
	x += 10000
	y += 10000

	d = sqrt( (x-x0)**2 + (y-y0)**2 )
	if d < min_d
		min_d = d
		min_d2 = (x-x0)**2 + (y-y0)**2
	end

	x0, y0 = x, y

	blocks[y/B] ||= {}
	(blocks[y/B][x/B] ||= []) << point_idx
	points << x * (W+1) + y
}

(0..n-1).each{|idx0|
	x0, y0 = points[idx0] / (W+1), points[idx0] % (W+1)
	i0, j0 = y0/B, x0/B
	for i in [i0-(min_d/B).ceil, 0].max..[i0+(min_d/B).ceil, W/B].min
		dy = ((i-i0).abs-1) * B

		for j in [j0-(min_d/B).ceil, 0].max..[j0+(min_d/B).ceil, W/B].min
			next unless blocks[i]
			next unless blocks[i][j]
			dx = ((j-j0).abs-1) * B
			next if dx > 0 && dx*dx + dy*dy > min_d**2

			blocks[i][j].each{|idx1|
				next if idx0 >= idx1
				x1, y1 = points[idx1] / (W+1), points[idx1] % (W+1)
				d = sqrt( (x1-x0)**2 + (y1-y0)**2 )
				if d < min_d
					min_d = d
					min_d2 = (x1-x0)**2 + (y1-y0)**2
				end
			}
		end
	end
}

p min_d2