#include <bits/stdc++.h>
using namespace std;
struct point {
  int x, y, ind;
  char ch;
};
long long mod = 1e9 + 7;
long long powmod(long long a, long long b) {
  long long res = 1;
  a %= mod;
  assert(b >= 0);
  for (; b; b >>= 1) {
    if (b & 1) res = res * a % mod;
    a = a * a % mod;
  }
  return res;
}
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
long long fact[13];
void factorial() {
  fact[0] = 1;
  for (long long i = 1; i < 12; i++) fact[i] = (fact[i - 1] * i);
}
bool cmp(point A, point B) {
  if (A.x != B.x) return A.x < B.x;
  return A.y < B.y;
}
vector<long long> sie;
long long spf[1000007 + 7];
void sieve() {
  for (long long i = 2; i < 1000007; i++) {
    if (spf[i] == 0) {
      spf[i] = i;
      sie.push_back(i);
    }
    for (long long j = 0; j < ((long long)(sie).size()) &&
                          i * sie[j] <= 1000007 && sie[j] <= spf[i];
         j++)
      spf[i * sie[j]] = sie[j];
  }
}
const long long mx = 2e5 + 9;
long long n, a, b, _, ans, c, _1, _2, m, an, k, need, shuru, _3, _c, _a, _b,
    way, _0, mex, q, d, temp;
double dbl;
string st, st1, st2, isGood;
map<long long, long long> mm;
set<long long> ss;
vector<long long> path;
vector<long long> adj[102];
bool ok;
char ch;
long long vis[102], ar[mx];
long long graph[102][102];
void dfs(long long u) {
  vis[u] = 1;
  for (long long i = 0; i < ((long long)(adj[u]).size()); i++) {
    long long v = adj[u][i];
    if (!vis[v]) {
      if (graph[u][v] > 0)
        _1 += graph[u][v];
      else
        _2 += graph[u][v];
      dfs(adj[u][i]);
    }
  }
}
void f() {
  cin >> n;
  for (long long i = 0; i < n; i++) {
    cin >> _1 >> _2 >> _3;
    graph[_1 - 1][_2 - 1] = _3;
    graph[_2 - 1][_1 - 1] = -_3;
    adj[_1 - 1].push_back(_2 - 1);
    adj[_2 - 1].push_back(_1 - 1);
  }
  _1 = 0;
  _2 = 0;
  long long y = adj[0][1];
  if (graph[y][0] > 0)
    _1 += graph[y][0];
  else
    _2 += graph[y][0];
  dfs(0);
  cout << min(abs(_1), abs(_2)) << "\n";
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cout << setprecision(12);
  f();
  return 0;
}
