#include <bits/stdc++.h>
const long long mod = 1000000000 + 7;
const long long INF = 9000000000000000000;
using namespace std;
void yes() { cout << "Yes" << endl; }
void no() { cout << "No" << endl; }
long long gcd(long long a, long long b) { return (a == 0 ? b : gcd(b % a, a)); }
long long lcm(long long a, long long b) { return (a * b / (gcd(a, b))); }
long long add(long long a, long long b, long long c = 0) {
  return ((a % mod + b % mod) % mod + c % mod) % mod;
}
long long mul(long long a, long long b) {
  return ((a % mod) * (b % mod)) % mod;
}
long long sub(long long a, long long b) {
  return (a % mod - b % mod + mod) % mod;
}
void print(vector<long long> ans) {
  for (auto x : ans) cout << x << " ";
  cout << endl;
}
int dx[] = {1, -1, 0, 0}, dy[] = {0, 0, 1, -1};
long long n, m, mx, timer, realans, cc, start, queries, startindex;
vector<pair<long long, long long> > arr[100005];
long long dp1[100005], dp2[100005];
void dfs(long long node = 1, long long parent = -1) {
  dp1[node] = 0, dp2[node] = 0;
  long long mx = 0;
  for (auto x : arr[node]) {
    long long child = x.first, weight = x.second;
    if (child != parent) {
      dfs(child, node);
      dp2[node] += (dp2[child] + 2 * weight);
      mx = max(mx, dp2[child] - dp1[child] + weight);
    }
  }
  dp1[node] = dp2[node] - mx;
}
void solve() {
  cin >> n;
  long long sum = 0;
  for (long long i = 1; i < n; i++) {
    long long u, v, w;
    cin >> u >> v >> w;
    arr[u].push_back({v, w}), arr[v].push_back({u, w});
    sum += w;
  }
  dfs();
  cout << dp1[1] << endl;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  long long tests = 1;
  while (tests--) {
    solve();
  }
  return 0;
}
