#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> v[n + 1];
  vector<pair<int, int> > r[n + 1];
  bool visited[n + 1];
  for (int i = 0; i < n + 1; i++) visited[i] = 0;
  int a, b, c;
  for (int i = 0; i < n; i++) {
    cin >> a >> b >> c;
    v[a].push_back(b);
    v[b].push_back(a);
    r[a].push_back(make_pair(b, c));
  }
  vector<int> path;
  path.push_back(1);
  visited[1] = 1;
  int next = v[1][0];
  path.push_back(next);
  while (next != 1) {
    visited[next] = 1;
    if (!visited[v[next][0]]) {
      path.push_back(v[next][0]);
      next = v[next][0];
    } else if (!visited[v[next][1]]) {
      path.push_back(v[next][1]);
      next = v[next][1];
    } else {
      path.push_back(1);
      next = 1;
    }
  }
  int one = 0, two = 0;
  for (int i = 0; i < (int)path.size() - 1; i++) {
    int e = path[i];
    int f = path[i + 1];
    if (r[e].size() && r[e][0].first == f)
      two += r[e][0].second;
    else if (r[e].size() > 1 && r[e][1].first == f)
      two += r[e][1].second;
    else if (r[f][0].first == e)
      one += r[f][0].second;
    else if (r[f][1].first == e)
      one += r[f][1].second;
  }
  cout << min(one, two) << endl;
  return 0;
}
