#include <bits/stdc++.h>
using namespace std;
const int inf = 1e5 + 9;
int n;
int mp[9];
bool done[109];
vector<pair<long long, pair<long long, long long> > > v[109];
void dfs(int node) {
  done[node] = 1;
  for (int i = 0; i < v[node].size(); i++) {
    int u = v[node][i].first;
    int e = v[node][i].second.first;
    int f = v[node][i].second.second;
    if (done[u]) continue;
    mp[f] += e, dfs(u);
  }
}
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0), cin >> n;
  for (int i = 0; i < n; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    a--;
    b--;
    v[a].push_back({b, {c, 1}});
    v[b].push_back({a, {c, 0}});
  }
  dfs(0);
  mp[1 - v[0][1].second.second] += v[0][1].second.first;
  cout << min(mp[1], mp[0]) << endl;
}
