#include <bits/stdc++.h>
using namespace std;
vector<pair<int, int>> adj[101];
long long int vis[101];
long long int x = 0;
long long int fxp(long long int a, long long int b) {
  if (b == 0) return 1;
  if (b % 2 == 0) {
    long long int c = fxp(a, b / 2);
    return (c * c) % 1000000007;
  }
  return (a * fxp(a, b - 1)) % 1000000007;
}
int lcm(int c, int d) {
  int a = c;
  int b = d;
  int ans;
  if (a >= b) {
    while (b != 0) {
      int x = b;
      b = a % b;
      a = x;
    }
    ans = (c * d) / a;
  } else {
    while (a != 0) {
      int x = a;
      a = b % a;
      b = x;
    }
    ans = (c * d) / b;
  }
  return ans;
}
int root_find() {
  long long int x;
  for (int i = 1; i < 100001; i++) {
    if (adj[i].size() == 1) {
      x = i;
      break;
    }
  }
  return x;
}
void dfs(int s, int y) {
  vis[s] = 1;
  for (int i = 0; i < adj[s].size(); i++) {
    if (adj[s][i].first == y) continue;
    if (vis[adj[s][i].first] == 0 || adj[s][i].first == 1) {
      if (adj[s][i].second != 0) {
        x = x + adj[s][i].second;
      }
      dfs(adj[s][i].first, s);
    }
  }
}
bool isPrime(long long int n) {
  if (n <= 1) return false;
  if (n <= 3) return true;
  if (n % 2 == 0 || n % 3 == 0) return false;
  for (int i = 5; i * i <= n; i = i + 6)
    if (n % i == 0 || n % (i + 2) == 0) return false;
  return true;
}
long long int smallestDivisor(long long int n) {
  if (n % 2 == 0) return n / 2;
  for (int i = 3; i * i <= n; i += 2) {
    if (n % i == 0) return n / i;
  }
  return n;
}
bool sortbysec(const pair<int, int> &a, const pair<int, int> &b) {
  return (a.second < b.second);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  long long int n;
  cin >> n;
  for (int i = 0; i <= 100; i++) {
    vis[i] = 0;
  }
  while (n--) {
    long long int a, b, c;
    cin >> a >> b >> c;
    adj[a].push_back(make_pair(b, 0));
    adj[b].push_back(make_pair(a, c));
  }
  dfs(1, adj[1][0].first);
  long long int ans = x;
  x = 0;
  for (int i = 0; i < 101; i++) vis[i] = 0;
  dfs(1, adj[1][1].first);
  ans = min(ans, x);
  cout << ans << '\n';
  return 0;
}
