#include <bits/stdc++.h>
using namespace std;
int a[101][101];
bool visited[500001];
vector<vector<long long>> c(500001);
long long cnt = 0, ans = 0;
void dfs(long long i, long long n) {
  if (cnt == n) return;
  visited[i] = true;
  int mn = -1, index = -1;
  cnt++;
  for (long long j = 1; j <= n; j++) {
    if (a[i][j] != 0 && visited[j] == false) {
      if (mn == -1 || a[i][j] < mn) {
        mn = a[i][j];
        index = j;
      }
    }
  }
  if (mn == -1) {
    for (int j = 1; j <= n; j++) {
      if (a[j][i] != 0 && visited[j] == false) {
        mn = a[j][i];
        index = j;
      }
    }
    if (mn == -1 || cnt == n) {
      if (a[i][1] == 0)
        ans += a[1][i];
      else
        ans += 0;
    } else
      ans += mn;
    dfs(index, n);
  } else {
    dfs(index, n);
  }
}
void solve() {
  long long n, e;
  cin >> n;
  for (long long i = 0; i < 101; i++)
    for (long long j = 0; j < 101; j++) a[i][j] = 0;
  long long to = 0;
  for (long long i = 0; i < n; i++) {
    long long first, second, z;
    cin >> first >> second >> z;
    a[first][second] = z;
    to += z;
  }
  for (long long i = 0; i < 1 + n; i++) visited[i] = false;
  dfs(1, n);
  cout << min(ans, to - ans);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long t = 1;
  while (t--) {
    solve();
  }
}
