#include <bits/stdc++.h>
using namespace std;
vector<pair<int, int> > v[(int)1e5 + 3];
long long mx = 0;
void solve(int i, int sum) {
  if (v[i].size() == 0) {
    if (sum > mx) {
      mx = sum;
    }
    return;
  }
  for (int j = 0; j < v[i].size(); j++) {
    solve(v[i][j].first, sum + v[i][j].second);
  }
}
long long solve2(int i) {
  int sum = 0;
  for (int j = 0; j < v[i].size(); j++) {
    sum += v[i][j].second + solve2(v[i][j].first);
    v[i][j].second = 0;
  }
  return sum;
}
int main() {
  int n;
  cin >> n;
  int x, y, w;
  pair<int, int> p;
  for (int i = 0; i < n - 1; i++) {
    cin >> x >> y >> w;
    p.first = max(x, y);
    p.second = w;
    v[min(x, y)].push_back(p);
  }
  solve(1, 0);
  long long sum = 2 * solve2(1) - mx;
  cout << sum;
  return 0;
}
