#include <bits/stdc++.h>
using namespace std;
int n, root = 0, curr = 0;
vector<vector<int>> adj, cost;
vector<bool> used;
void dfs(int v) {
  used[v] = true;
  for (auto u : adj[v])
    if (!used[u]) {
      curr += cost[v][u];
      dfs(u);
    }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  adj.resize(n);
  cost.assign(n, vector<int>(n));
  int total = 0;
  for (int i = 0; i < n; i++) {
    int u, v, c;
    cin >> u >> v >> c;
    u -= 1;
    v -= 1;
    total += c;
    adj[u].push_back(v);
    adj[v].push_back(u);
    cost[u][v] = 0;
    cost[v][u] = c;
  }
  used.assign(n, false);
  dfs(root);
  curr += cost[adj[root][1]][root];
  cout << min(curr, total - curr) << endl;
}
