#include <bits/stdc++.h>
using namespace std;
int n, ret;
vector<pair<int, int> > edge[105];
void dfs(int pre, int u) {
  if (u == 1) return;
  for (int i = 0; i < edge[u].size(); i++) {
    int v = edge[u][i].first;
    int w = edge[u][i].second;
    if (v == pre) continue;
    ret += w;
    dfs(u, v);
  }
}
int main() {
  while (scanf("%d", &n) != EOF) {
    for (int i = 0; i < n; i++) {
      int u, v, w;
      scanf("%d%d%d", &u, &v, &w);
      edge[u].push_back(make_pair(v, 0));
      edge[v].push_back(make_pair(u, w));
    }
    int ans = 0x3f3f3f3f;
    for (int i = 0; i < edge[1].size(); i++) {
      int v = edge[1][i].first;
      ret = edge[1][i].second;
      dfs(1, v);
      ans = min(ans, ret);
    }
    printf("%d\n", ans);
  }
  return 0;
}
