#include <bits/stdc++.h>
using namespace std;
int const MOD = (int)1e9 + 7;
inline void normal(long long &a) {
  a %= MOD;
  (a < 0) && (a += MOD);
}
inline long long modMul(long long a, long long b) {
  a %= MOD, b %= MOD;
  normal(a), normal(b);
  return (a * b) % MOD;
}
inline long long modAdd(long long a, long long b) {
  a %= MOD, b %= MOD;
  normal(a), normal(b);
  return (a + b) % MOD;
}
inline long long modSub(long long a, long long b) {
  a %= MOD, b %= MOD;
  normal(a), normal(b);
  a -= b;
  normal(a);
  return a;
}
inline long long modPow(long long b, long long p) {
  long long r = 1;
  while (p) {
    if (p & 1) r = modMul(r, b);
    b = modMul(b, b);
    p >>= 1;
  }
  return r;
}
inline long long modInverse(long long a) { return modPow(a, MOD - 2); }
inline long long modDiv(long long a, long long b) {
  return modMul(a, modInverse(b));
}
inline long long mod(long long a, long long m) {
  if (a < 0)
    return m - (abs(a) % m);
  else if (a < m)
    return a;
  else
    return (a % m);
}
const int N = 200007;
const int MAX = 1000005;
vector<int> g[N], cost[N];
int vis[N];
long long sub[N];
vector<pair<long long, long long> > sum;
long long ans = 0;
bool cmp(pair<long long, long long> a, pair<long long, long long> b) {
  return a.first > b.first;
}
void bfs(int s) {
  queue<int> q;
  q.push(s);
  vis[s] = 1;
  while (q.size() > 0) {
    int top = q.front();
    q.pop();
    for (int i = 0; i < g[top].size(); i++) {
      int x = g[top][i];
      if (vis[x] == 0) {
        sub[x] = sub[top] + (long long)cost[top][i];
        vis[x] = 1;
        q.push(x);
      }
    }
  }
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  if (n == 1) {
    cout << 0 << endl;
    return 0;
  }
  for (int i = 0; i < n - 1; i++) {
    int x, y, z;
    cin >> x >> y >> z;
    g[x].push_back(y);
    g[y].push_back(x);
    cost[x].push_back(z);
    cost[y].push_back(z);
    ans += z;
  }
  memset(sub, 0, sizeof(sub));
  bfs(1);
  for (int i = 1; i <= n; i++) {
    if (g[i].size() == 1) {
      sum.push_back({sub[i], i});
    }
  }
  sort(sum.begin(), sum.end(), cmp);
  ans -= sum[0].first;
  cout << sum[0].first + 2 * ans << endl;
}
