#include <bits/stdc++.h>
using namespace std;
int mat[105][105];
bool flag[105];
vector<int> vc;
int main() {
  int nodes, i, j, k, n, u, v, c, sum1, sum2, fcnt;
  cin >> nodes;
  for (i = 1; i <= nodes; i++)
    for (j = 1; j <= nodes; j++) mat[i][j] = 1000;
  sum1 = sum2 = 0;
  for (i = 1; i <= nodes; i++) {
    cin >> u >> v >> c;
    mat[v][u] = 0;
    mat[u][v] = c;
  }
  for (i = 1; i <= nodes; i++) flag[i] = false;
  fcnt = 0;
  vc.push_back(1);
  flag[1] = true;
  fcnt++;
  for (i = 1; i <= nodes; i++)
    for (j = 1; j <= nodes; j++)
      if ((mat[vc[i - 1]][j] == 0 || mat[vc[i - 1]][j] <= 100) &&
          (!flag[j] || fcnt == nodes)) {
        flag[j] = true;
        fcnt++;
        vc.push_back(j);
        sum1 += mat[vc[i - 1]][j];
        mat[vc[i - 1]][j] = 1000;
        break;
      }
  for (i = 1; i <= nodes; i++) flag[i] = false;
  fcnt = 0;
  vc.clear();
  vc.push_back(1);
  flag[1] = true;
  fcnt++;
  for (i = 1; i <= nodes; i++)
    for (j = 1; j <= nodes; j++)
      if ((mat[vc[i - 1]][j] == 0 || mat[vc[i - 1]][j] <= 100) &&
          (!flag[j] || fcnt == nodes)) {
        flag[j] = true;
        fcnt++;
        vc.push_back(j);
        sum2 += mat[vc[i - 1]][j];
        mat[vc[i - 1]][j] = 1000;
        break;
      }
  cout << min(sum1, sum2);
  return 0;
}
