#include <bits/stdc++.h>
using namespace std;
const int N = 1e2 + 5;
const long long int infP = 1e18;
vector<long long int> a[N];
map<pair<long long int, long long int>, long long int> mp;
long long int dfs(long long int u, long long int p) {
  long long int ans = 1e18;
  if (u == 1 and p != -1) return 0;
  for (auto v : a[u]) {
    if (v != p) ans = min(ans, mp[{u, v}] + dfs(v, u));
  }
  return ans;
}
void solve() {
  long long int n;
  cin >> n;
  for (long long int i = 1; i <= n; i++) {
    long long int u, v, c;
    cin >> u >> v >> c;
    a[u].push_back(v);
    a[v].push_back(u);
    mp[{u, v}] = 0;
    mp[{v, u}] = c;
  }
  cout << dfs(1, -1);
}
void debug(long long int tt) {}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int t = 1;
  while (t--) {
    solve();
  }
}
