#!/usr/bin/env python3
from math import sqrt

ps = sorted(list(map(int, input().split())) for _ in range(int(input())))

# ans ~ 5*10^5 < 10**6
# average x-distance between points: 10^9/10^5 = 10^4
# covering 100 consecutive points is sufficient.

# I wanted to use math.dist instead of math.sqrt, but apparently, that's three times slower...
print(min(sqrt((x1 - x2) ** 2 + (y1 - y2) ** 2 + (z1 - z2) ** 2)
          for i, (x1, y1, z1) in enumerate(ps) for x2, y2, z2 in ps[max(0, i - 100):i]))
