#include <cstdio>
#include <cmath>
#include <algorithm>

using namespace std;

const int N = (int)1e6;

int n, x[N], y[N], p[N], p2[N];
double best = (int)1e9; // infinity

bool xless( int i, int j ) { return x[i] < x[j]; }
bool yless( int i, int j ) { return y[i] < y[j]; }

int sqr( int x ) { return x * x; }

double distance( int i, int j ) { return sqrt(sqr(x[i] - x[j]) + sqr(y[i] - y[j])); }

// [l, r)
void Solve( int l, int r )
{
  if (r - l <= 1)
    return;

  int m = (l + r) / 2, xx = x[m];
  Solve(l, m);
  Solve(m, r);

  // sort [1..n] : y1 < y2 < y3 < ... < yn
  // T(n) = nlogn + 2T(n/2) = nlog^2n

  merge(p + l, p + m, p + m, p + r, p2 + l, yless);
  copy(p2 + l, p2 + r, p + l);
  // T(n)= n + 2T(n/2) = nlogn

  // |x[i] - x[m]| <= best
  int k = 0;
  for (int i = l; i < r; i++)
    if (abs(x[p[i]] - xx) < best)
      p2[k++] = p[i];

  forn(i, k)
  {
    // <= 6
    for (int j = i + 1; j < k && y[p2[j]] - y[p2[i]] <= best; j++)
      best = min(best, distance(p2[i], p2[j]));
  }
}


int main()
{
  scanf("%d", &n);
  forn(i, n)
    scanf("%d%d", &x[i], &y[i]), p[i] = i;
  sort(p, p + n, xless);
  Solve(0, n);
}