#include <bits/stdc++.h>
using namespace std;
const double EPS = 1e-12;
const double PI = 3.14159265359;
enum dir {
  DOWN = 0,
  UP,
  RIGHT,
  LEFT,
  DOWN_RIGHT,
  DOWN_LEFT,
  UP_RIGHT,
  UP_LEFT
};
int dir_r[] = {1, -1, 0, 0, 1, 1, -1, -1};
int dir_c[] = {0, 0, 1, -1, 1, -1, 1, -1};
bool vis[100000];
vector<vector<int>> v(10000);
int x, y;
map<pair<int, int>, int> m, p;
void dfs(int n) {
  vis[n] = 1;
  for (int w : v[n]) {
    if (!p[{n, w}]) {
      x += m[{n, w}];
      y += m[{w, n}];
      p[{n, w}] = 1;
      p[{w, n}] = 1;
    }
    if (!vis[w]) {
      dfs(w);
    }
  }
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    int x, y, c;
    cin >> x >> y >> c;
    v[x].push_back(y);
    v[y].push_back(x);
    m[{x, y}] = 0;
    m[{y, x}] = c;
  }
  dfs(1);
  cout << min(x, y);
  return 0;
}
