#include <bits/stdc++.h>
using namespace std;
string itoa(int i) {
  stringstream ss;
  ss << i;
  return ss.str();
}
int m[101][101];
int cost = 1000000;
int N;
void go(int start, int next, int _cost) {
  if (next == 1) {
    if (m[start][next] == 0) {
      _cost += m[next][start];
    }
    cost = min(cost, _cost);
    return;
  }
  int _next = 0;
  for (int i = (1); i <= (N); ++i) {
    if (m[next][i] > 0 && i != start) {
      _next = i;
      break;
    }
    if (m[i][next] > 0 && i != start) {
      _next = i;
      break;
    }
  }
  if (m[start][next] > 0) {
    go(next, _next, _cost);
  } else {
    go(next, _next, _cost + m[next][start]);
  }
}
int main() {
  int n = 0;
  vector<int> cand;
  cin >> N;
  memset(m, 0, sizeof(m));
  while (n < N) {
    int u, v, c;
    cin >> u >> v >> c;
    m[u][v] = c;
    if (u == 1) cand.push_back(v);
    if (v == 1) cand.push_back(u);
    n++;
  }
  for (int i = (0); i < (((int)(cand).size())); ++i) {
    go(1, cand[i], 0);
  }
  cout << cost << endl;
  return 0;
}
