#include <bits/stdc++.h>
using namespace std;
const char NL = '\n';
long long int mod = 1000000007;
clock_t startTime;
double getCurrentTime() {
  return (double)(clock() - startTime) / CLOCKS_PER_SEC;
}
void read(vector<long long int> &a) {
  for (auto &it : a) cin >> it;
}
struct ele {
  long long int val;
  long long int dir;
  long long int cost;
};
vector<bool> vis(101);
long long int dfs(long long int proot, long long int root,
                  vector<vector<struct ele>> &g) {
  if (vis[root] || (root == 1 && proot != -1)) return 0;
  vis[root] = 1;
  long long int cost = 0;
  long long int mcost = LLONG_MAX;
  for (struct ele i : g[root]) {
    if (i.val != proot) {
      if (i.dir == 0) {
        cost += i.cost;
      }
      cost += dfs(root, i.val, g);
      mcost = min(mcost, cost);
    }
  }
  return mcost;
}
inline void solve() {
  long long int n;
  cin >> n;
  vector<vector<struct ele>> g(n + 1);
  long long int totalcost = 0;
  for (long long int i = 0; i < n; i++) {
    long long int x, y, c;
    cin >> x >> y >> c;
    totalcost += c;
    g[x].push_back({y, 1, c});
    g[y].push_back({x, 0, c});
  }
  long long int cost = dfs(-1, 1, g);
  cout << min(cost, totalcost - cost) << NL;
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  startTime = clock();
  solve();
  fflush(stdin);
  fflush(stdout);
  return 0;
}
