#include <bits/stdc++.h>
using namespace std;
const long double PI = acos(-1);
const long long MOD = 1000000007;
const long long FMOD = 998244353;
vector<pair<long long, long long> > v[100005];
long long d = 0;
void dfs(long long src, long long par, long long dist) {
  d = max(d, dist);
  for (auto x : v[src]) {
    if (x.first == par) continue;
    dfs(x.first, src, dist + x.second);
  }
}
void solve() {
  long long n;
  cin >> n;
  long long tot = 0;
  for (long long i = 0; i < n - 1; i++) {
    long long x, y, w;
    cin >> x >> y >> w;
    v[x].push_back({y, w});
    v[y].push_back({x, w});
    tot += w;
  }
  tot *= 2;
  dfs(1, 0, 0);
  cout << tot - d << endl;
}
signed main() { solve(); }
