#include <bits/stdc++.h>
using namespace std;
vector<pair<int, int> > g[100];
int ans = 0, n, s = 0;
bool vis[100];
void dfs(int v) {
  vis[v] = true;
  for (int i = 0; i < 2; ++i) {
    int to = g[v][i].first;
    if (!vis[to] && to) {
      if (g[v][i].second > 0) {
        ans += g[v][i].second;
      }
      dfs(to);
      return;
    }
  }
  for (int i = 0; i < 2; ++i) {
    int to = g[v][i].first;
    if (!to) {
      if (g[v][i].second > 0) {
        ans += g[v][i].second;
        dfs(to);
      }
    }
  }
}
void solve() {
  memset(vis, false, sizeof(vis));
  if (g[0][0].second > 0) {
    ans += g[0][0].second;
  }
  dfs(g[0][0].first);
}
int main(int argc, char *argv[]) {
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    int from, to, dist;
    scanf("%d%d%d", &from, &to, &dist);
    from--;
    to--;
    g[from].push_back(make_pair(to, dist));
    g[to].push_back(make_pair(from, -dist));
    s += dist;
  }
  solve();
  printf("%d", min(ans, s - ans));
  return 0;
}
