#include <bits/stdc++.h>
using namespace std;
long long int em(long long int x, long long int Mod, long long int n) {
  if (n == 0)
    return 1ll;
  else if (n % 2 == 0)
    return em((x % Mod * x % Mod) % Mod, Mod, n / 2) % Mod;
  else
    return (x % Mod * em((x % Mod * x % Mod) % Mod, Mod, (n - 1) / 2)) % Mod;
}
vector<pair<long long int, long long int> > v[100002];
long long int dist[100002], vis[100002];
long long int djikstra(long long int n) {
  long long int i, j, k;
  priority_queue<pair<long long int, long long int> > q;
  q.push({0, 1});
  while (!q.empty()) {
    pair<long long int, long long int> u = q.top();
    long long int x = u.second;
    q.pop();
    vis[x] = 1;
    for (pair<long long int, long long int> y : v[x]) {
      if (vis[y.first] == 1) continue;
      if (dist[y.first] < dist[x] + y.second) {
        dist[y.first] = dist[x] + y.second;
        q.push({dist[y.first], y.first});
      }
    }
  }
  long long int maxi = 0;
  for (i = 1; i <= n; i++) maxi = max(maxi, dist[i]);
  return maxi;
}
int32_t main() {
  std::ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int n, i, j, k, l;
  cin >> n;
  long long int ans = 0;
  for (long long int i = (long long int)0; i < (long long int)n - 1; i++) {
    cin >> j >> k >> l;
    v[j].push_back({k, l});
    v[k].push_back({j, l});
    ans += 2 * l;
  }
  ans -= djikstra(n);
  cout << ans << "\n";
}
