#include <bits/stdc++.h>
using namespace std;
int n;
const int nax = 107;
vector<vector<int>> edge;
vector<bool> vis(nax);
vector<vector<int>> dp(nax, vector<int>(nax));
int ans;
int k;
void dfs(int node) {
  vis[node] = true;
  for (int i = 0; i < 2; i++) {
    k = edge[node][i];
    if (!vis[k]) {
      ans += dp[node][k];
      dfs(k);
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n;
  edge.resize(n);
  int sum = 0;
  for (int i = 0; i < n; i++) {
    int u, v, cost;
    cin >> u >> v >> cost;
    --u, --v;
    edge[u].push_back(v);
    edge[v].push_back(u);
    dp[u][v] = cost;
    sum += cost;
  }
  dfs(0);
  ans += dp[k][0];
  cout << min(ans, sum - ans) << endl;
}
