#include <bits/stdc++.h>
using namespace std;
long long ans, visited[100009];
vector<pair<long long, long long>> adj[100009];
long long dfs(int s, int dist) {
  visited[s] = 1;
  long long mx = dist;
  for (auto u : adj[s]) {
    if (!visited[u.second]) mx = max(mx, dfs(u.second, dist + u.first));
  }
  return mx;
}
int main() {
  long long n, i, a, b, w;
  cin >> n;
  int bas;
  for (i = 1; i < n; i++) {
    cin >> a >> b >> w;
    adj[a].push_back({w, b});
    adj[b].push_back({w, a});
    ans += 2 * w;
  }
  cout << ans - dfs(1, 0);
}
