#include <bits/stdc++.h>
using namespace std;
int w[111][111];
vector<int> a[111];
int vis[111];
int ans, n;
void dfs(int u, int cur, int sum1, int sum2) {
  if (cur == n) {
    if (w[u][1] > 0)
      sum1 += w[u][1];
    else
      sum2 -= w[u][1];
    ans = min(sum1, sum2);
    return;
  }
  vis[u] = 1;
  for (int i = 0; i < a[u].size(); i++) {
    int v = a[u][i];
    if (!vis[v]) {
      if (w[u][v] >= 0)
        dfs(v, cur + 1, sum1 + w[u][v], sum2);
      else
        dfs(v, cur + 1, sum1, sum2 - w[u][v]);
    }
  }
}
int main() {
  int i, j, u, v, f;
  while (scanf("%d", &n) != EOF) {
    memset(vis, 0, sizeof(vis));
    for (i = 1; i <= n; i++) a[i].clear();
    for (i = 0; i < n; i++) {
      scanf("%d%d%d", &u, &v, &f);
      a[u].push_back(v);
      a[v].push_back(u);
      w[u][v] = f;
      w[v][u] = -f;
    }
    ans = 100000000;
    dfs(1, 1, 0, 0);
    printf("%d\n", ans);
  }
}
