#include <bits/stdc++.h>
using namespace std;
const int MAXn = 100;
int adj[MAXn + 5][MAXn + 5];
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    int u, v, c;
    cin >> u >> v >> c;
    u--;
    v--;
    adj[u][v] = c;
    adj[v][u] = -1 * c;
  }
  bool dir = 0;
  int sum[2] = {0, 0}, u = -1, v = 0;
  for (int i = 0; i < n; i++)
    if (adj[v][i] > 0) dir = 1;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++)
      if (adj[v][j] != 0 && j != u) {
        if (dir) {
          if (adj[v][j] > 0)
            sum[dir] += adj[v][j];
          else {
            sum[!dir] += -1 * adj[v][j];
            dir = !dir;
          }
        } else {
          if (adj[v][j] > 0) {
            sum[!dir] += adj[v][j];
            dir = !dir;
          } else
            sum[dir] += -1 * adj[v][j];
        }
        u = v;
        v = j;
        break;
      }
  }
  cout << min(sum[0], sum[1]) << endl;
  return 0;
}
