#include <bits/stdc++.h>
using namespace std;
const int Max = 1e9 + 100;
const long long int MAX = 1e18 + 500;
const long long int sz = 1e5 + 100;
long long int sum[sz];
long long int ans;
vector<pair<long long int, long long int> > ad[sz];
void DFS(long long int p, long long int par) {
  for (auto xx : ad[p]) {
    if (xx.first != par) {
      DFS(xx.first, p);
      sum[p] += (sum[xx.first] + 2ll * xx.second);
    }
  }
}
void fun(long long int p, long long int par, long long int last) {
  last += sum[p];
  long long int ct = 0;
  for (auto xx : ad[p]) {
    if (xx.first != par) {
      long long int temp = last;
      temp -= (xx.second + sum[xx.first]);
      fun(xx.first, p, temp);
      ++ct;
    }
  }
  if (ct == 0) ans = min(ans, last);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long int a, b, c, i, j, k, q, p, x, y, ct, ct1, m, l, r, x1, y1, mn, h,
      sum1, in, z, mid, n, mx;
  char ch;
  double d;
  string str1, str2, str;
  bool bl, bl1;
  int t, cs = 1;
  cin >> n;
  for (int i = 1; i < n; i++) {
    cin >> p >> q >> x;
    ad[p].push_back({q, x});
    ad[q].push_back({p, x});
  }
  ans = MAX;
  DFS(1, -1);
  fun(1, -1, 0);
  cout << ans << '\n';
}
