## subroutines

def dist2(p0, p1)
  (p1[0] - p0[0]) ** 2 + (p1[1] - p0[1]) ** 2
end

def pdist_rec(i, j)
  ij = j - i
  return 0 if ij <= 1
  return dist2($pts[i], $pts[i + 1]) if ij == 2

  if ij == 3
    return [dist2($pts[i], $pts[i + 1]),
            dist2($pts[i + 1], $pts[i + 2]),
            dist2($pts[i + 2], $pts[i])].min
  end

  k = (i + j) / 2
  d2 = [pdist_rec(i, k), pdist_rec(k, j)].min
  d = Math.sqrt(d2 + 0.5).to_i

  midx = $pts[k][0]
  spts = []

  (k - 1).downto(i) do |i0|
    break if midx - $pts[i0][0] >= d
    spts << $pts[i0]
  end

  for j0 in (k...j)
    break if $pts[j0][0] - midx >= d
    spts << $pts[j0]
  end

  spts.sort!{|a, b| a[1] <=> b[1]}
  nspts = spts.length

  for i0 in (0...nspts)
    for j0 in ((i0 + 1)...nspts)
      break if spts[j0][1] - spts[i0][1] >= d
      sd2 = dist2(spts[i0], spts[j0])
      if d2 > sd2
        d2 = sd2
        d = Math.sqrt(d2 + 0.5).to_i
      end
    end
  end

  d2
end

### main

n = gets.strip.to_i

$pts = n.times.map{gets.strip.split(' ').map{|s| s.to_i}}.sort
#p $pts

d2 = pdist_rec(0, n)
puts d2