#include <bits/stdc++.h>
using namespace std;
long long resultSet;
long long already[100008];
vector<pair<long long, long long>> arrayM[100008];
long long functionOf(int something, int length) {
  already[something] = 1;
  int min = -100;
  long long noth = length;
  for (auto u : arrayM[something]) {
    int mm = 0;
    if (!already[u.second]) {
      noth = max(noth, functionOf(u.second, length + u.first));
    } else {
      mm++;
    }
  }
  return noth;
}
int main() {
  long long nano;
  long long iago;
  long long ani;
  long long i;
  long long basa, wifi;
  cin >> nano;
  for (i = 1; i < nano; i++) {
    cin >> ani;
    cin >> basa;
    cin >> wifi;
    arrayM[ani].push_back({wifi, basa});
    arrayM[basa].push_back({wifi, ani});
    long long k = 2 * wifi;
    resultSet += k;
  }
  long long result = resultSet - functionOf(1, 0);
  cout << result;
}
