#include <bits/stdc++.h>
using namespace std;
int array1[101][4];
int cost[101][101];
int count1[101];
int getval(int i) {
  int ans1 = 0, ans2 = 0;
  int prev = i;
  int temp = array1[i][0];
  if (array1[i][1] == -1) {
    ans1 += cost[temp][i];
  }
  while (temp != i) {
    int newtemp;
    if (array1[temp][0] != prev) {
      newtemp = array1[temp][0];
      if (array1[temp][1] == -1) {
        ans1 += cost[temp][newtemp];
      }
    } else {
      newtemp = array1[temp][2];
      if (array1[temp][3] == -1) {
        ans1 += cost[temp][newtemp];
      }
    }
    prev = temp;
    temp = newtemp;
  }
  prev = i;
  temp = array1[i][2];
  if (array1[i][3] == -1) {
    ans2 += cost[temp][i];
  }
  while (temp != i) {
    int newtemp;
    if (array1[temp][0] != prev) {
      newtemp = array1[temp][0];
      if (array1[temp][1] == -1) {
        ans2 += cost[temp][newtemp];
      }
    } else {
      newtemp = array1[temp][2];
      if (array1[temp][3] == -1) {
        ans2 += cost[temp][newtemp];
      }
    }
    prev = temp;
    temp = newtemp;
  }
  return min(ans1, ans2);
}
int main() {
  int n;
  cin >> n;
  memset(array1, 0, sizeof(array1));
  memset(count1, 0, sizeof(count1));
  memset(cost, 0, sizeof(cost));
  for (int i = 0; i < n; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    array1[a][2 * count1[a]] = b;
    array1[a][2 * count1[a] + 1] = 1;
    array1[b][2 * count1[b]] = a;
    array1[b][2 * count1[b] + 1] = -1;
    count1[a]++;
    count1[b]++;
    cost[a][b] = c;
    cost[b][a] = c;
  }
  int val = 0;
  for (int i = 1; i < n; i++) {
    if (array1[i][1] == array1[i][3]) {
      val = getval(i);
      break;
    }
  }
  cout << val;
  return 0;
}
