#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
long long lcm(long long a, long long b) { return (a * b) / gcd(a, b); }
long long min(long long a, long long b) { return a < b ? a : b; }
long long max(long long a, long long b) { return a > b ? a : b; }
long long max3(long long a, long long b, long long c) {
  return max(max(a, b), c);
}
long long max4(long long a, long long b, long long c, long long d) {
  return max(max(a, b), max(c, d));
}
long long min3(long long a, long long b, long long c) {
  return min(min(a, b), c);
}
long long min4(long long a, long long b, long long c, long long d) {
  return min(min(a, b), min(c, d));
}
long long po(long long x, long long n, long long mod = 1000000007) {
  if (n == 0) {
    return 1;
  }
  long long m = po(x, n / 2, mod);
  m *= m;
  m %= mod;
  if (n % 2) {
    m *= x;
    m %= mod;
  }
  return m;
}
long long n;
vector<long long> down_up(1000000, 0), down(1000000, 0);
vector<pair<long long, long long>> adj[1000000];
void dfs(long long u, long long parent) {
  long long mi = LLONG_MAX;
  for (long long i = 0; i < adj[u].size(); i++) {
    if (adj[u][i].first != parent) {
      dfs(adj[u][i].first, u);
      down_up[u] += down_up[adj[u][i].first] + 2 * adj[u][i].second;
    }
  }
  for (long long i = 0; i < adj[u].size(); i++) {
    if (adj[u][i].first != parent) {
      mi = min(mi, -down_up[adj[u][i].first] + down[adj[u][i].first] -
                       adj[u][i].second);
    }
  }
  if (mi == LLONG_MAX) {
    mi = 0;
  }
  down[u] = down_up[u] + mi;
}
int32_t main() {
  cin.tie(0);
  cout.tie(0);
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  clock_t startTime = clock();
  cout << fixed << setprecision(12);
  cin >> n;
  for (long long i = 0; i < n - 1; i++) {
    long long a, b, w;
    cin >> a >> b >> w;
    adj[a].push_back({b, w});
    adj[b].push_back({a, w});
  }
  dfs(1, 0);
  cout << down[1] << "\n";
}
