#include <bits/stdc++.h>
using namespace std;
int n;
vector<vector<pair<int, int>>> g;
int main() {
  ios::sync_with_stdio(false);
  cin >> n;
  g.resize(n + 1, vector<pair<int, int>>());
  for (int i = 0; i < (int)(n); i++) {
    int a, b, c;
    cin >> a >> b >> c;
    g[a].push_back(make_pair(b, 0));
    g[b].push_back(make_pair(a, c));
  }
  stack<int> st;
  int costfd = 0, costbk = 0, prev = -1;
  st.push(1);
  while (true) {
    int curv = st.top();
    st.pop();
    int nxtv = -1;
    for (int i = 0; i < (int)(g[curv].size()); i++) {
      if (g[curv][i].first != prev) {
        nxtv = g[curv][i].first;
        costfd += g[curv][i].second;
        for (int j = 0; j < (int)(g[nxtv].size()); j++) {
          if (g[nxtv][j].first == curv) {
            costbk += g[nxtv][j].second;
            break;
          }
        }
        break;
      }
    }
    if (nxtv == 1) break;
    prev = curv;
    st.push(nxtv);
  }
  cout << min(costfd, costbk);
}
