#include <bits/stdc++.h>
using namespace std;
const long double eps = 1e-9, pi = acos(-1.0);
const long long inf = 2000000009;
int n, a, b, c;
int cost1 = 0, cost2 = 0;
vector<vector<int> > g;
vector<char> u;
map<pair<int, int>, int> M;
map<pair<int, int>, int>::iterator it;
void dfs(int v, int p) {
  for (int i = 0; i < g[v].size(); i++) {
    if (!u[g[v][i]] && g[v][i] != p) {
      u[g[v][i]] = 1;
      it = M.find(make_pair(v, g[v][i]));
      if (it != M.end()) {
        cost2 += it->second;
      } else {
        it = M.find(make_pair(g[v][i], v));
        cost1 += it->second;
      }
      dfs(g[v][i], v);
    }
  }
}
void solve() {
  cin >> n;
  g.resize(n);
  u.resize(n);
  for (int i = 0; i < n; i++) {
    cin >> a >> b >> c;
    a--, b--;
    g[a].push_back(b);
    g[b].push_back(a);
    M.insert(make_pair(make_pair(a, b), c));
  }
  dfs(0, 0);
  cout << min(cost1, cost2);
}
int main() { solve(); }
