#include <bits/stdc++.h>
using namespace std;
vector<pair<long long, long long>> adj[(long long)1e5];
long long path = 0;
void dfs(long long u, long long par, long long ans) {
  path = max(path, ans);
  for (auto i : adj[u]) {
    if (i.first == par) continue;
    ans += i.second;
    dfs(i.first, u, ans);
    ans -= i.second;
  }
}
void solve() {
  long long n, u, v, w;
  cin >> n;
  long long total = 0;
  for (long long i = 0; i < n - 1; i++) {
    cin >> u >> v >> w;
    u--;
    v--;
    total += 2 * w;
    adj[u].push_back({v, w});
    adj[v].push_back({u, w});
  }
  dfs(0, -1, 0);
  cout << total - path << endl;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  solve();
}
