#include <bits/stdc++.h>
using namespace std;
vector<int> getPath(const vector<vector<int> >& g) {
  int n = (int)g.size();
  vector<int> res(n);
  int p = 0, last = -1;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j)
      if (j != last) {
        if (g[p][j] != 0 || g[j][p] != 0) {
          last = p;
          p = res[i] = j;
          break;
        }
      }
  }
  return res;
}
int main() {
  int n;
  cin >> n;
  vector<vector<int> > g(n, vector<int>(n, 0));
  for (int i = 0; i < n; ++i) {
    int a, b, l;
    cin >> a >> b >> l;
    g[a - 1][b - 1] = l;
  }
  vector<int> p = getPath(g);
  int r1 = 0, r2 = 0;
  for (int i = 1; i <= n; ++i) {
    r1 += g[p[i % n]][p[i - 1]];
    r2 += g[p[i - 1]][p[i % n]];
  }
  cout << min(r1, r2);
  return 0;
}
