def root(x): p=x l=[p] while r[p]!=p: p=r[p] l.append(p) for p in l: r[p]=l[-1] return r[x] def union(x,y): rx=root(x) ry=root(y) if rx>ry: rx,ry=ry,rx r[ry]=rx return n=int(input()) e=[] for i in range((n*(n-1))//2): a,b,c=map(int,input().split()) a-=1 b-=1 e+=[(c,a,b)] e.sort() l=0 r=list(range(n)) for c,a,b in e: if root(a)!=root(b): union(a,b) l=c print(l)