#include <bits/stdc++.h>
using namespace std;
const int MAXN = 101;
int g[MAXN][2];
int cost[MAXN][2];
int f(int v, int prev, int result) {
  if (v == 1) return result;
  for (int i = 0; i < 2; i++) {
    int w = g[v][i];
    if (w == prev) continue;
    return f(g[v][i], v, result + cost[v][i]);
  }
}
void addEdge(int a, int b, int c) {
  int tmp = g[a][0] == 0 ? 0 : 1;
  g[a][tmp] = b;
  cost[a][tmp] = c;
}
int main() {
  int n;
  scanf("%d", &n);
  memset(g, 0, sizeof(g));
  for (int i = 0; i < n; i++) {
    int a, b, c;
    scanf("%d %d %d", &a, &b, &c);
    addEdge(a, b, 0);
    addEdge(b, a, c);
  }
  printf("%d\n", min(f(g[1][0], 1, cost[1][0]), f(g[1][1], 1, cost[1][1])));
}
