#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, a, b, c, x, y;
  scanf("%d", &n);
  int edges[n + 1][2];
  memset(edges, -1, sizeof(edges));
  int cost[n + 1][n + 1];
  memset(cost, -1, sizeof(cost));
  for (int i = int(0); i < int(n); i++) {
    scanf("%d", &a);
    scanf("%d", &b);
    scanf("%d", &c);
    cost[a][b] = c;
    if (edges[a][0] == -1) {
      edges[a][0] = b;
    } else {
      edges[a][1] = b;
    }
    if (edges[b][0] == -1) {
      edges[b][0] = a;
    } else {
      edges[b][1] = a;
    }
  }
  int k = 1;
  vector<int> ring;
  ring.push_back(1);
  ring.push_back(edges[1][0]);
  x = edges[1][0];
  y = 1;
  while (x != 1) {
    if (edges[x][0] != y) {
      ring.push_back(edges[x][0]);
      y = x;
      x = edges[x][0];
    } else {
      ring.push_back(edges[x][1]);
      y = x;
      x = edges[x][1];
    }
  }
  int m1 = 0;
  int m2 = 0;
  for (int i = int(0); i < int(n); i++) {
    if (cost[ring[i]][ring[i + 1]] != -1) m1 += cost[ring[i]][ring[i + 1]];
    if (cost[ring[i + 1]][ring[i]] != -1) m2 += cost[ring[i + 1]][ring[i]];
  }
  printf("%d\n", min(m1, m2));
}
