#include <bits/stdc++.h>
using namespace std;
vector<int> neigh[100];
int n;
int ct;
int order[100];
bool visited[100];
int price[100][100];
bool direc[100][100];
int min(int a, int b) {
  if (a < b) return a;
  return b;
}
void makegraph(int start) {
  order[ct] = start;
  visited[start] = true;
  ++ct;
  if (!visited[neigh[start][0]])
    makegraph(neigh[start][0]);
  else if (!visited[neigh[start][1]])
    makegraph(neigh[start][1]);
}
int main() {
  cin >> n;
  ct = 0;
  int sum = 0;
  int need = 0;
  for (int i = 0; i < 100; ++i) {
    visited[i] = false;
    order[i] = -1;
  }
  for (int i = 0; i < n; ++i) {
    int j, k, mon;
    cin >> j >> k >> mon;
    j--;
    k--;
    price[j][k] = mon;
    price[k][j] = mon;
    direc[j][k] = true;
    direc[k][j] = false;
    neigh[j].push_back(k);
    neigh[k].push_back(j);
    sum += mon;
  }
  makegraph(0);
  for (int i = 0; i < n; ++i) {
    if (direc[order[i % n]][order[(i + 1) % n]] == false)
      need += price[order[i % n]][order[(i + 1) % n]];
  }
  cout << min(need, sum - need) << endl;
}
