#include <bits/stdc++.h>
using namespace std;
int n, t1, t2, t3, l, min1, sum, mark[200];
vector<pair<int, int> > adj[200];
int dfs(int ras) {
  l++;
  mark[ras] = 1;
  for (int i = 0; i < adj[ras].size(); i++) {
    if (!mark[adj[ras][i].first]) {
      sum += adj[ras][i].second;
      mark[adj[ras][i].first] = 1;
      dfs(adj[ras][i].first);
      return 0;
    } else if (l == n - 1 && adj[ras][i].first == 1) {
      sum += adj[ras][i].second;
      return 0;
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> t1 >> t2 >> t3;
    adj[t1].push_back(make_pair(t2, 0));
    adj[t2].push_back(make_pair(t1, t3));
  }
  for (int i = 0; i < 200; i++) mark[i] = 0;
  mark[1] = 1;
  sum = adj[1][0].second;
  dfs(adj[1][0].first);
  min1 = sum;
  for (int i = 0; i < 200; i++) mark[i] = 0;
  l = 0;
  mark[1] = 1;
  sum = adj[1][1].second;
  dfs(adj[1][1].first);
  cout << min(min1, sum);
  return 0;
}
