#include <bits/stdc++.h>
using namespace std;
vector<vector<int> > gr;
vector<bool> used;
map<pair<int, int>, int> v;
int ans;
void dfs(int v, int b = -1) {
  if (v) used[v] = true;
  for (int i = 0; i < gr[v].size(); ++i) {
    int to = gr[v][i];
    if (!used[to] && to != b) {
      ans += ::v[make_pair(v, to)];
      dfs(to, v);
    }
  }
}
int main(void) {
  int n;
  cin >> n;
  gr.resize(n);
  used.resize(n, false);
  int s = 0;
  for (int i = 0, a, b, c; i < n; i++) {
    cin >> a >> b >> c;
    --a, --b;
    gr[a].push_back(b);
    gr[b].push_back(a);
    v[make_pair(a, b)] = c;
    s += c;
  }
  dfs(0);
  cout << min(ans, s - ans);
  return 0;
}
