#include <bits/stdc++.h>
using namespace std;
int main() {
  cout << fixed;
  cout.precision(9);
  int n;
  cin >> n;
  vector<pair<pair<int, int>, int> > e(n);
  int s1 = 0, s2 = 0;
  for (int i = 0; i < n; i++) {
    int a, b, s;
    cin >> e[i].first.first >> e[i].first.second >> e[i].second;
    e[i].first.first--;
    e[i].first.second--;
  }
  vector<int> next(n, -1);
  int i = e[0].first.first;
  int j = e[0].first.second;
  do {
    next[i] = j;
    i = next[i];
    for (j = 0; j < n; j++) {
      if (e[j].first.first == i && next[e[j].first.second] != i) {
        j = e[j].first.second;
        break;
      }
      if (e[j].first.second == i && next[e[j].first.first] != i) {
        j = e[j].first.first;
        break;
      }
    }
  } while (i != e[0].first.first);
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++) {
      if (e[j].first.first == i && next[e[j].first.second] != i) {
        next[i] = e[j].first.second;
        break;
      }
      if (e[j].first.second == i && next[e[j].first.first] != i) {
        next[i] = e[j].first.first;
        break;
      }
    }
  for (int i = 0; i < n; i++) {
    if (next[e[i].first.first] == e[i].first.second)
      s1 += e[i].second;
    else
      s2 += e[i].second;
  }
  cout << min(s1, s2) << endl;
  return 0;
}
