#include <bits/stdc++.h>
using namespace std;
vector<pair<int, int> > v[100010];
int ans = 0, vis[100010], co = 0, n;
void dfs(int i) {
  vis[i] = 1;
  co++;
  if (co == n) {
    for (int j = 0; j < v[i].size(); j++)
      if (v[i][j].first == -1) ans += v[i][j].second;
    return;
  }
  for (int j = 0; j < v[i].size(); j++) {
    if (vis[abs(v[i][j].first)] != 1) {
      if (v[i][j].first < 0) {
        ans += v[i][j].second;
        dfs(-v[i][j].first);
      } else
        dfs(v[i][j].first);
    }
  }
}
int main() {
  int i, sum = 0;
  cin >> n;
  for (i = 0; i < n; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    sum += c;
    v[a].push_back(make_pair(b, c));
    v[b].push_back(make_pair(-a, c));
  }
  dfs(1);
  if (sum - ans < ans) ans = sum - ans;
  cout << ans << endl;
}
