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

#define INF 2100000000

using std::sort;
using std::pair;
using std::make_pair;

int n;
pair<int, int> ship[100002];
pair<int, int> buffer[100002];

int process(int st, int ed)
{
	if (ed <= st)
	{
		return INF;
	}

	int mid = (st + ed) / 2;

	int left = process(st, mid);
	int right = process(mid + 1, ed);
	int minValue = (left < right) ? left : right;

	int leftFoc = st;
	int rightFoc = mid + 1;
	int insertFoc = st;

	while (leftFoc <= mid && rightFoc <= ed)
	{
		if (ship[leftFoc].second < ship[rightFoc].second
		|| (ship[leftFoc].second == ship[rightFoc].second
			&& ship[leftFoc].first < ship[rightFoc].first))
		{
			buffer[insertFoc++] = ship[leftFoc++];
		}
		else
		{
			buffer[insertFoc++] = ship[rightFoc++];
		}
	}

	while (leftFoc <= mid)
        {
		buffer[insertFoc++] = ship[leftFoc++];
	}

	while (rightFoc <= ed)
	{
		buffer[insertFoc++] = ship[rightFoc++];
	}

	for(int i=st; i<=ed; i++)
	{
		ship[i] = buffer[i];
	}

	for(int i=st; i<=ed; i++)
	{
		for(int j=i+1; j<=ed && j<=i+16; j++)
		{
			int dist = (ship[i].first-ship[j].first)*(ship[i].first-ship[j].first) + (ship[i].second-ship[j].second)*(ship[i].second-ship[j].second);
			
			if (dist < minValue)
			{
				minValue = dist;
			}
		}
	}

	return minValue;
}

int main()
{
	FILE *fin = fopen("input.txt", "r");
	FILE *fout = fopen("output.txt", "w");

	fscanf(fin, "%d", &n);

	for(int i=0; i<n; i++)
	{
		fscanf(fin, "%d %d", &ship[i].first, &ship[i].second);
	}

	sort(ship, ship + n);

	int out = process(0,  n - 1);	


	fprintf(fout, "%.0lf", sqrt(out));

	fclose(fin);
	fclose(fout);

	return 0;
}
