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 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]
        # pre_sort by axis_X
        p_list.sort(key=attrgetter('real'))

        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_idx = array_length // 2
        div_line = array[mid_idx].real
        d_min = min(self.closest_pair(array[:mid_idx], mid_idx),
                self.closest_pair(array[mid_idx:], array_length - mid_idx))

        # sort array_part by axis_Y while recursively comparing
        array.sort(key=attrgetter('imag'))

        min_stack = list()
        for ele in array:
            size = len(min_stack)

            if abs(ele.real - div_line) >= d_min:
                continue

            for j in range(size):
                alt = ele - min_stack[size - j - 1]
                if alt.imag >= d_min:
                    break
                d_min = min(d_min, abs(alt))

            min_stack.append(ele)

        return d_min


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