#include <bits/stdc++.h>
using namespace std;
const long long INF = numeric_limits<long long>::max() - 1;
const int MAXN = 100 + 10;
int n, cost[MAXN][MAXN];
vector<int> adj[MAXN];
int dfs(int u, int v) {
  if (v == 0) return cost[u][v];
  int w;
  if (adj[v][0] == u)
    w = adj[v][1];
  else
    w = adj[v][0];
  return cost[u][v] + dfs(v, w);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n;
  for (int qwe = 0; qwe < (int)n; qwe++) {
    int u, v, c;
    cin >> u >> v >> c;
    u--;
    v--;
    adj[u].push_back(v);
    adj[v].push_back(u);
    cost[u][v] = 0;
    cost[v][u] = c;
  }
  cout << min(dfs(0, adj[0][0]), dfs(0, adj[0][1]));
  return 0;
}
