Problem: For given n points in metric space, find the distance of the closest points.

Constraints

* 2 ≤ n ≤ 100,000
* -100 ≤ x, y ≤ 100

Input


n
x0 y0
x1 y1
:
xn-1 yn-1


The first integer n is the number of points.

In the following n lines, the coordinate of the i-th point is given by two real numbers xi and yi. Each value is a real number with at most 6 digits after the decimal point.

Output

Print the distance in a line. The output values should be in a decimal fraction with an error less than 0.000001.

Examples

Input

2
0.0 0.0
1.0 0.0


Output

1.000000


Input

3
0.0 0.0
2.0 0.0
1.0 1.0


Output

1.41421356237

Solution (in PYTHON3):

Solution:
#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""
input:
3
0.0 0.0
2.0 0.0
1.0 1.0

output:
1.41421356237
"""

import math
import sys
from operator import attrgetter


class ClosestPair(object):
    def __init__(self, ):
        """
        Init closest pairs points set.
        """
        _input = sys.stdin.readlines()
        p_num = int(_input[0])
        points = map(lambda x: x.split(), _input[1:])
        p_list = [complex(float(x), float(y)) for x, y in points]
        p_list.sort(key=attrgetter('real'))
        # assert len(p_list) == p_num
        # print(p_list)
        ans = self.closest_pair(array=p_list, array_length=p_num)
        print(('{:.6f}'.format(ans)))

    def closest_pair(self, array, array_length):
        if array_length <= 1:
            return float('inf')
        mid = array_length // 2
        mid_real = array[mid].real
        d = min(self.closest_pair(array[:mid], mid).real,
                self.closest_pair(array[mid:], array_length - mid).real)

        return self.brute_force(array, mid_real, d)

    @staticmethod
    def brute_force(array, mid_real, d=float('inf')):
        array.sort(key=attrgetter('imag'))
        min_stack = list()
        for ele in array:
            size = len(min_stack)
            if abs(ele.real - mid_real) >= d:
                continue

            for j in range(size):
                dx = ele.real - min_stack[size - j - 1].real
                dy = ele.imag - min_stack[size - j - 1].imag
                if dy >= d:
                    break
                d = min(d, math.sqrt(dx ** 2 + dy ** 2))

            min_stack.append(ele)

        return d


if __name__ == '__main__':
    case = ClosestPair()