#include <bits/stdc++.h>
using namespace std;
vector<pair<long long, long long> > adj[100100];
long long under[100100];
long long n;
long long dfs(long long u, long long p) {
  under[u] = 0;
  long long next, edge;
  for (long long i = 0; i < adj[u].size(); i++) {
    next = adj[u][i].first;
    edge = adj[u][i].second;
    if (next != p) {
      under[u] += edge + dfs(next, u);
    }
  }
  return under[u];
}
long long f(long long u, long long p) {
  long long sum = 0;
  long long edge, next;
  for (long long i = 0; i < adj[u].size(); i++) {
    next = adj[u][i].first;
    edge = adj[u][i].second;
    if (next != p) sum += edge + under[next];
  }
  if (sum == 0) return 0;
  long long best = 100000000ll * 100000000ll;
  long long now;
  for (long long i = 0; i < adj[u].size(); i++) {
    next = adj[u][i].first;
    edge = adj[u][i].second;
    if (next != p) {
      now = (sum - (edge + under[next])) * 2 + edge + f(next, u);
      best = min(best, now);
    }
  }
  return best;
}
int main() {
  cin >> n;
  long long x, y, edge;
  for (long long i = 1; i < n; i++) {
    cin >> x >> y >> edge;
    adj[x].push_back(pair<long long, long long>(y, edge));
    adj[y].push_back(pair<long long, long long>(x, edge));
  }
  dfs(1, -1);
  cout << f(1, -1) << endl;
  return 0;
}
