import sys input = sys.stdin.readline N = int(input()) e = [[] for _ in range(N + 1)] for _ in range(N * (N - 1) // 2): u, v, c = map(int, input().split()) e[u].append((v, c, 0)) e[v].append((u, c, 0)) import heapq class prim: def __init__(self, n, e): self.e = e self.n = n def MSTcost(self): h = [] visited = [0] * (self.n + 1) b = pow(10, 6) for edge in e[1]: heapq.heappush(h, edge[1] * b ** 2 + edge[0] * b + edge[2]) res = 0 reslist = [] visited[1] = 1 while len(h): p = heapq.heappop(h) p01 = p // b p2 = p % b p0 = p01 // b p1 = p01 % b if visited[p1]: continue visited[p1] = 1 for q in self.e[p1]: if visited[q[0]]: continue heapq.heappush(h, q[1] * b ** 2 + q[0] * b + q[2]) res += p0 reslist.append(p2) return res, reslist pri = prim(N, e) cost = pri.MSTcost()[0] ok = 10 ** 100 ng = 0 while ok - ng > 1: m = (ok + ng) // 2 me = [[] for _ in range(N + 1)] for x in range(1, N + 1): for y, c, _ in e[x]: if c <= m: me[x].append((y, c, 0)) pri = prim(N, me) mst = pri.MSTcost() if mst[0] == cost and len(mst[1]) == N - 1: ok = m else: ng = m print(ok)