from collections import deque n=int(input()) g=[[] for _ in range(n)] for _ in range(n*(n-1)//2): a,b,c=map(int,input().split()) a-=1;b-=1 g[a].append((b,c)) g[b].append((a,c)) def f(d): visit=[False]*n q=deque() q.append(0) while q: now=q.popleft() if visit[now]: continue visit[now]=True for to,cost in g[now]: if cost>d: continue if visit[to]: continue q.append(to) for i in visit: if i==False: return False return True r=10**100 l=0 while r-l>1: mid=(l+r)//2 if f(mid): r=mid else: l=mid print(r)