#include <bits/stdc++.h>
using namespace std;
vector<pair<int, int>> v[333];
int visited[333];
bool f = 0;
int maxx = 0, cost = 0, n, steps = 0;
void dfs(int s, int prev) {
  if (visited[1] > 1) {
    return;
  }
  visited[s]++;
  for (auto x : v[s]) {
    if (!visited[x.first] || x.first == 1) {
      if (x.first == prev) continue;
      cost += x.second;
      dfs(x.first, s);
    }
  }
}
int main() {
  int n, a, b, c;
  memset(visited, 0, sizeof visited);
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a >> b >> c;
    v[a].push_back({b, 0});
    v[b].push_back({a, c});
    maxx += c;
  }
  dfs(1, 0);
  cout << min(maxx - cost, cost) << endl;
}
