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

blocks = Array.new(W/B+1)
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] ||= Array.new(W/B+1)
	(blocks[y/B][x/B] ||= []) << point_idx
	points << [x, y]
}

(0..n-1).each{|idx0|
	x0, y0 = points[idx0]
	i0, j0 = y0/B, x0/B
	for i in 0..blocks.size-1
		dy = [(i-i0).abs-1, 0].max * B
		next if dy > min_d

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

			blocks[i][j].each{|idx1|
				x1, y1 = points[idx1]
				next if idx0 >= idx1
				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