#include <bits/stdc++.h>
using namespace std;
struct node {
  vector<int> adj;
  vector<int> wt;
  vector<bool> rev;
} graph[200];
int* visited;
int find(int cur, int prev, bool val, int ans) {
  if (visited[cur] == 1) {
    return ans;
  }
  visited[cur] = 1;
  for (int i = 0; i < graph[cur].adj.size(); i++) {
    int v = graph[cur].adj[i];
    int wt = graph[cur].wt[i];
    bool reversed = graph[cur].rev[i];
    if (v != prev) {
      if (reversed == val)
        return find(v, cur, val, ans + wt);
      else
        return find(v, cur, val, ans);
    }
  }
}
int main(void) {
  int n;
  scanf("%d", &n);
  int e = n;
  int u, v, w;
  int total = 0;
  while (e--) {
    scanf("%d %d %d", &u, &v, &w);
    total += w;
    graph[u].adj.push_back(v);
    graph[u].wt.push_back(w);
    graph[u].rev.push_back(false);
    graph[v].adj.push_back(u);
    graph[v].wt.push_back(w);
    graph[v].rev.push_back(true);
  }
  visited = (int*)calloc(n + 10, sizeof(int));
  int oneway = find(1, -1, true, 0);
  int other = total - oneway;
  printf("%d\n", min(oneway, other));
  return 0;
}
