#include using namespace std; struct UnionFind{ vector par; vector rank; UnionFind(int n){ par.resize(n); rank.resize(n); for(int i = 0; i < n; i++){ par[i] = i; rank[i] = 1; } } int root(int x){ if(par[x] == x) return x; else return par[x] = root(par[x]); } bool same(int x, int y){ return root(x) == root(y); } void unite(int x, int y){ x = root(x); y = root(y); if(x == y) return; if(rank[x] < rank[y]) swap(x, y); par[y] = x; rank[x] += rank[y]; } int size(int x) { return rank[root(x)]; } }; int main(){ int N; cin >> N; vector a(N * (N - 1) / 2), b(N * (N - 1) / 2); vector T(N * (N - 1) / 2); for(int i = 0; i < N * (N - 1) / 2; i++){ cin >> a[i] >> b[i] >> T[i]; } int lb = -1, ub = N * (N - 1) / 2; while(ub - lb > 1){ int mid = (ub + lb) / 2; UnionFind U(N); for(int i = 0; i <= mid; i++){ U.unite(a[i], b[i]); } if(U.size(a[0]) == N) ub = mid; else lb = mid; } cout << T[ub] << endl; }