#include <bits/stdc++.h>
using namespace std;
int N;
int g[110][110];
int dfs(int cur, int d, int prev, int cnt) {
  if (cnt == 0) return 0;
  int st = d == 1 ? 1 : N;
  int end = N + 1 - st + d;
  int res = 0;
  for (int i = st; i != end; i += d) {
    if (g[cur][i] != 0 && i != prev) {
      if (g[cur][i] < 0) res += labs(g[cur][i]);
      res += dfs(i, d, cur, cnt - 1);
      break;
    }
  }
  return res;
}
int main() {
  cin >> N;
  for (int i = 0; i < N; ++i) {
    int a, b, c;
    cin >> a >> b >> c;
    g[a][b] = c;
    g[b][a] = -c;
  }
  int res = dfs(1, 1, -1, N);
  res = min(res, dfs(1, -1, -1, N));
  cout << res;
  return 0;
}
