#include <bits/stdc++.h>
using namespace std;
const long long int N = 1e5 + 100;
long long int n;
vector<pair<long long int, long long int> > adj[N];
long long int dp[N];
bool mark[N];
void dfs(long long int v) {
  mark[v] = 1;
  for (auto u : adj[v]) {
    if (!mark[u.first]) {
      dfs(u.first);
      dp[v] = max(dp[u.first] + u.second, dp[v]);
    }
  }
}
long long int ans;
long long int total;
int32_t main() {
  cin >> n;
  for (long long int i = 0; i < n - 1; i++) {
    long long int x, y, z;
    cin >> x >> y >> z;
    x--;
    y--;
    adj[x].push_back({y, z});
    adj[y].push_back({x, z});
    total += z;
  }
  dfs(0);
  ans = dp[0];
  total *= (long long int)2;
  total -= ans;
  cout << total;
}
