import sys input=lambda:sys.stdin.readline().rstrip() def find(par,i): if par[i]==-1: return i root=find(par,par[i]) par[i]=root return root def unite(par,i,j): par[find(par,i)]=find(par,j) N=int(input()) par=[-1 for i in range(N)] ans=0 for i in range(N*(N-1)//2): a,b,C=map(int,input().split()) if find(par,a-1)!=find(par,b-1): unite(par,a-1,b-1) ans=max(ans,C) print(ans)