#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 123;
const int mod = 1e9 + 7;
const int INF = 1e9 + 1;
const long long INFL = 1e18 + 1;
const double eps = 1e-9;
const double pi = acos(-1.0);
int n;
vector<pair<int, long long> > g[N];
long long sum, mx, d[N];
set<pair<long long, int> > q;
inline void djikstra(int st) {
  q.insert(make_pair(0, st));
  fill(d + 1, d + n + 1, INFL);
  d[st] = 0;
  while (!q.empty()) {
    int v = q.begin()->second;
    q.erase(q.begin());
    for (int i = 0; i < g[v].size(); i++) {
      int to = g[v][i].first, cost = g[v][i].second;
      if (d[v] + cost < d[to]) {
        q.erase(make_pair(d[to], to));
        d[to] = d[v] + cost;
        q.insert(make_pair(d[to], to));
      }
    }
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie();
  cin >> n;
  int m = n - 1;
  for (int i = 1; i <= m; i++) {
    int x, y, z;
    cin >> x >> y >> z;
    sum += z + z;
    g[x].push_back(make_pair(y, z));
    g[y].push_back(make_pair(x, z));
  }
  djikstra(1);
  for (int i = 2; i <= n; i++) mx = max(mx, (d[i] != INFL ? d[i] : -1));
  cout << sum - mx;
  return 0;
}
