def dis(p,q)
    return ((p[0]-q[0])**2+(p[1]-q[1])**2)
end

n=gets.to_i
ps=[]
n.times do
    ps.push(gets.split.map(&:to_i))
end
ps.sort!{|a,b|a[0]<=>b[0]}
res=[]
for i in 0..n-2
    res.push(dis(ps[i],ps[i+1]))
end
ps.sort!{|a,b|a[1]<=>b[1]}
for i in 0..n-2
    res.push(dis(ps[i],ps[i+1]))
end
p res.min
