#include <bits/stdc++.h>
using namespace std;
class Node {
 public:
  list<int> adj;
} node[2000];
int flag[200];
int main() {
  int i, j, n;
  cin >> n;
  map<int, int> mp;
  for (i = 0; i < n; ++i) {
    int x, y, cost;
    cin >> x >> y >> cost;
    node[x].adj.push_back(y);
    node[y].adj.push_back(x);
    mp[x * 1000 + y] = cost;
  }
  long long mi = 1000000000;
  for (i = 1; i <= n; ++i) flag[i] = 0;
  flag[1] = 1;
  long long c = 0;
  int cur = 1;
  while (1) {
    int next = *node[cur].adj.begin();
    if (flag[next] == 1) next = *(++node[cur].adj.begin());
    if (flag[next] == 1) {
      next = 1;
    }
    if (mp.find(next * 1000 + cur) != mp.end())
      c += mp.find(next * 1000 + cur)->second;
    flag[next] = 1;
    cur = next;
    if (cur == 1) break;
  }
  mi = c;
  c = 0;
  cur = 1;
  for (i = 1; i <= n; ++i) flag[i] = 0;
  flag[1] = 1;
  while (1) {
    int next = *(--node[cur].adj.end());
    if (flag[next] == 1) next = *(node[cur].adj.begin());
    if (flag[next] == 1) {
      next = 1;
    }
    if (mp.find(next * 1000 + cur) != mp.end())
      c += mp.find(next * 1000 + cur)->second;
    flag[next] = 1;
    cur = next;
    if (cur == 1) break;
  }
  if (mi > c) mi = c;
  cout << mi;
}
