#!/usr/bin/env python3 # from typing import * import sys import io import math import collections import decimal import itertools import bisect import heapq def input(): return sys.stdin.readline()[:-1] # sys.setrecursionlimit(1000000) # _INPUT = """# paste here... # """ # sys.stdin = io.StringIO(_INPUT) INF = 10**101 class UnionFind(): parents = [] sizes = [] count = 0 def __init__(self, n): self.count = n self.parents = [i for i in range(n)] self.sizes = [1 for i in range(n)] def find(self, i): if self.parents[i] == i: return i else: self.parents[i] = self.find(self.parents[i]) return self.parents[i] def unite(self, i, j): root_i = self.find(i) root_j = self.find(j) if root_i == root_j: return elif root_i < root_j: self.parents[root_j] = root_i self.sizes[root_i] += self.sizes[root_j] else: self.parents[root_i] = root_j self.sizes[root_j] += self.sizes[root_i] def same(self, i, j): return self.find(i) == self.find(j) def size(self, i): return self.sizes[self.find(i)] def group_count(self): return len(set(self.find(i) for i in range(self.count))) N = int(input()) L = [] for _ in range(N*(N-1)//2): a, b, c = map(int, input().split()) L.append((c, a-1, b-1)) L.sort() uf = UnionFind(N) ans = 0 for c, a, b in L: if uf.same(a, b): continue uf.unite(a, b) ans = max(ans, c) print(ans)