#include <bits/stdc++.h>
using namespace std;
const long long N = 2e5 + 100;
const long long inf = 1e18, mod = 1e9 + 7;
long long n, x, y, c, a[110][110];
vector<long long> adj[110];
long long check(long long u) {
  long long ans = 0;
  if (!a[1][u]) ans += a[u][1];
  long long now = 1;
  while (u != 1) {
    long long help = ((adj[u][0] != now) ? adj[u][0] : adj[u][1]);
    if (!a[u][help]) ans += a[help][u];
    now = u;
    u = help;
  }
  return ans;
}
int main() {
  ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  cin >> n;
  for (int i = 1; i <= n; i++)
    cin >> x >> y >> c, a[x][y] = c, adj[x].push_back(y), adj[y].push_back(x);
  return cout << min(check(adj[1][0]), check(adj[1][1])) << endl, 0;
}
