#include <bits/stdc++.h>
void initf() {}
using namespace std;
const int inf = 1 << 30;
int n;
int g[101][101];
bool gt[101][101];
vector<int> order;
int do1() {
  int S = order[0];
  int ret = 0;
  for (int i = 0; i < (n); ++i) {
    int T = order[(i + 1) % n];
    if (g[S][T] >= inf) ret += g[T][S];
    S = T;
  }
  return (ret);
}
int do2() {
  reverse((order).begin(), (order).end());
  int S = order[0];
  int ret = 0;
  for (int i = 0; i < (n); ++i) {
    int T = order[(i + 1) % n];
    if (g[S][T] == inf) ret += g[T][S];
    S = T;
  }
  return (ret);
}
bool mark[101];
void dfs(int v) {
  mark[v] = true;
  order.push_back(v);
  for (int i = 0; i < (n); ++i)
    if (!mark[i] && gt[v][i]) dfs(i);
}
void solve() {
  cin >> n;
  for (int i = 0; i < (n); ++i)
    for (int j = 0; j < (n); ++j) g[i][j] = inf;
  for (int i = 0; i < (n); ++i) {
    int x, y, z;
    cin >> x >> y >> z;
    --x;
    --y;
    g[x][y] = z;
    gt[x][y] = gt[y][x] = true;
  }
  dfs(0);
  int ret = inf;
  ret = min(ret, do1());
  ret = min(ret, do2());
  cout << ret << endl;
}
int main() {
  initf();
  solve();
  return (0);
}
