#include <bits/stdc++.h>
using namespace std;
vector<pair<int, int>> adj[101];
int n, sum, x;
vector<bool> used(101, false);
int dfs(int vertex, int cost, int num) {
  used[vertex] = true;
  int ans = INT_MAX;
  for (int i = 0; i < 2; ++i) {
    int aa = adj[vertex][i].first;
    int bb = adj[vertex][i].second;
    if (!used[aa])
      ans = min(ans, dfs(aa, cost + bb, num + 1));
    else if (aa == 1 && num == n) {
      return cost + bb;
    }
  }
  return ans;
}
int main() {
  int a, b, c;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> a >> b >> c;
    sum += c;
    adj[a].push_back({b, 0});
    adj[b].push_back({a, c});
  }
  x = dfs(1, 0, 1);
  cout << min(x, sum - x);
}
