#include <bits/stdc++.h>
using namespace std;
const int N_MAX = 110;
pair<int, int> edges[N_MAX][2];
int deg[N_MAX];
int main() {
  int N;
  scanf("%d", &N);
  for (int i = 0; i < N; ++i) {
    int u, v, c;
    scanf("%d %d %d", &u, &v, &c);
    --u;
    --v;
    edges[u][deg[u]++] = pair<int, int>(v, 0);
    edges[v][deg[v]++] = pair<int, int>(u, c);
  }
  int ans = 1e9;
  for (int w = 0; w < 2; ++w) {
    int u = edges[0][w].first;
    int curr = edges[0][w].second;
    int from = 0;
    while (u != 0) {
      for (int ei = 0; ei < 2; ++ei) {
        int v = edges[u][ei].first;
        if (v == from) continue;
        int cost = edges[u][ei].second;
        from = u;
        u = v;
        curr += cost;
        break;
      }
    }
    ans = min(ans, curr);
  }
  printf("%d\n", ans);
}
