N = int(input()) CAB = list() for e in range(N * (N - 1) // 2): A, B, C = map(int, input().split()) CAB.append((C, A - 1, B - 1)) CAB.sort() class DSU: def __init__(self, N: int) -> None: self.par = list(range(N)) self.sz = [1] * N def find(self, x: int) -> int: if self.par[x] != x: self.par[x] = self.find(self.par[x]) return self.par[x] def unite(self, x: int, y: int) -> bool: x, y = self.find(x), self.find(y) if x == y: return False if self.sz[x] < self.sz[y]: x, y = y, x self.par[y] = x self.sz[x] += self.sz[y] return True uf = DSU(N) for c, a, b in CAB: if uf.find(a) != uf.find(b): uf.unite(a, b) if uf.sz[uf.find(0)] == N: print(c) exit(0)