#include <bits/stdc++.h>
using namespace std;
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
void in(vector<long long int> &v) {
  for (long long int i = 0; i < v.size(); i++) cin >> v[i];
}
void out(vector<long long int> v) {
  for (long long int i = 0; i < v.size(); i++) cout << v[i] << ' ';
  cout << '\n';
}
vector<long long int> adj[300005];
bool vis[300005];
map<pair<long long int, long long int>, long long int> m;
long long int cost1, cost2;
long long int c = 0, k;
long long int n;
bool f = false;
void dfs(long long int v) {
  vis[v] = true;
  c++;
  if (c == n and f == false) k = v, f = true;
  for (auto i : adj[v]) {
    if (vis[i] and i == 1 and v == k) {
      if (m.find(make_pair(v, i)) == m.end()) {
        cost1 += m[make_pair(i, v)];
      }
    }
    if (!vis[i]) {
      if (m.find(make_pair(v, i)) == m.end()) {
        cost1 += m[make_pair(i, v)];
      }
      dfs(i);
    }
  }
}
void dfs1(long long int v) {
  vis[v] = true;
  c++;
  if (c == n and f == false) k = v, f = true;
  for (auto i : adj[v]) {
    if (vis[i] and i == 1 and v == k) {
      if (m.find(make_pair(i, v)) == m.end()) {
        cost2 += m[make_pair(v, i)];
      }
    }
    if (!vis[i]) {
      if (m.find(make_pair(i, v)) == m.end()) {
        cost2 += m[make_pair(v, i)];
      }
      dfs1(i);
    }
  }
}
void solve() {
  cin >> n;
  long long int a = n;
  while (a--) {
    long long int x, y, c;
    cin >> x >> y >> c;
    m[make_pair(x, y)] = c;
    adj[x].push_back(y);
    adj[y].push_back(x);
  }
  dfs(1);
  c = 0;
  f = false;
  memset(vis, 0, sizeof(vis));
  dfs1(1);
  cout << min(cost1, cost2) << '\n';
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long int t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
