#include <bits/stdc++.h>
using namespace std;
int const N = 200001;
int n;
long long mx, an, d[N];
vector<pair<int, int> > g[N];
bool vs[N];
void go(int u) {
  vs[u] = 1;
  int l = 0;
  for (auto i : g[u]) {
    if (vs[i.second]) continue;
    d[i.second] = d[u] + i.first;
    go(i.second);
    l = 1;
  }
  if (!l) mx = max(mx, d[u]);
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n - 1; ++i) {
    int u, v, w;
    scanf("%d%d%d", &u, &v, &w);
    g[u].push_back({w, v});
    g[v].push_back({w, u});
    an = (long long)(an + w);
  }
  an = (1ll * an * 2);
  go(1);
  an -= mx;
  printf("%lld\n", an);
}
