#include <bits/stdc++.h>
using namespace std;
long long mod = 1e9 + 7;
long long min(long long a, long long b) { return (a < b) ? a : b; }
long long max(long long a, long long b) { return (a > b) ? a : b; }
long long fp(long long a, long long b) {
  if (b == 0) return 1;
  long long x = fp(a, b / 2);
  x = (x * x) % mod;
  if (b & 1) x = (x * a) % mod;
  return x;
}
vector<vector<pair<long long, long long>>> v(105);
vector<long long> vis(105);
long long x = 0, y = 0;
void dfs(long long node, long long p) {
  vis[node] = 1;
  for (auto &i : v[node]) {
    if (i.first == p) continue;
    if (!vis[i.first]) {
      if (i.second > 0)
        x += i.second;
      else
        y += i.second;
      dfs(i.first, node);
    } else if (i.second != 0 && p != -1) {
      if (i.second > 0)
        x += i.second;
      else
        y += i.second;
      i.second = 0;
    }
  }
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long n, x1, y1, c;
  cin >> n;
  for (long long i = 1; i <= n; i++) {
    cin >> x1 >> y1 >> c;
    v[x1].push_back({y1, c});
    v[y1].push_back({x1, -c});
  }
  dfs(1, -1);
  cout << min(x, -y);
}
