#include <bits/stdc++.h>
using namespace std;
int sum, vis[105], n;
int head[105], tot;
struct Edge {
  int u, v, w, next;
  Edge() {}
  Edge(int u, int v, int w) : u(u), v(v), w(w) {}
} edge[205];
void addedge(int u, int v, int w) {
  edge[tot] = Edge(u, v, w);
  edge[tot].next = head[u];
  head[u] = tot++;
}
void dfs(int u, int pre) {
  for (int i = head[u]; i != -1; i = edge[i].next) {
    int v = edge[i].v;
    if (v == pre || vis[v]) continue;
    sum += edge[i].w;
    vis[v] = 1;
    dfs(v, u);
  }
}
int main() {
  while (~scanf("%d", &n)) {
    memset(vis, 0, sizeof(vis));
    memset(head, -1, sizeof(head));
    tot = 0;
    sum = 0;
    int m = 0;
    for (int i = 0; i < n; i++) {
      int u, v, w;
      scanf("%d%d%d", &u, &v, &w);
      m += w;
      addedge(u, v, w);
      addedge(v, u, 0);
    }
    dfs(1, -1);
    printf("%d\n", min(sum, m - sum));
  }
  return 0;
}
