n=int(input()) x=[10**100]*n for i in range(n*(n-1)//2): a,b,c=map(int,input().split()) a-=1 b-=1 x[a]=min(c,x[a]) x[b]=min(c,x[b]) print(max(x))