#include <bits/stdc++.h>
using namespace std;
void fast() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}
vector<pair<pair<long long, long long>, bool> > adj[110];
long long cost = 0;
vector<bool> vis(110, 0);
void dfs(long long x) {
  vis[x] = true;
  for (auto child : adj[x]) {
    if (!vis[child.first.first] or
        (x == adj[1][1].first.first and child.first.first == 1)) {
      dfs(child.first.first);
      cost += child.first.second * child.second;
    }
  }
}
int32_t main() {
  fast();
  long long n;
  cin >> n;
  long long sum_weights = 0;
  for (long long i = 0; i < n; i++) {
    long long u, v, w;
    cin >> u >> v >> w;
    sum_weights += w;
    adj[u].push_back({{v, w}, 1});
    adj[v].push_back({{u, w}, 0});
  }
  dfs(1);
  cout << min(cost, sum_weights - cost) << "\n";
  return 0;
}
