#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
vector<pair<int, int> > g[N];
const int INF = 1e9;
int dist[N];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, u, v, w;
  cin >> n;
  long long int ans = 0;
  for (int i = 1; i < n; i++) {
    cin >> u >> v >> w;
    g[u].push_back(make_pair(v, w));
    g[v].push_back(make_pair(u, w));
    ans += 2 * w;
  }
  dist[1] = 0;
  for (int i = 2; i <= n; i++) {
    dist[i] = INF;
  }
  queue<int> q;
  q.push(1);
  while (!q.empty()) {
    u = q.front();
    q.pop();
    for (int i = 0; i < g[u].size(); i++) {
      v = g[u][i].first;
      if (dist[v] == INF) {
        dist[v] = dist[u] + g[u][i].second;
        q.push(v);
      }
    }
  }
  int mx = 0;
  for (int i = 1; i <= n; i++) mx = max(mx, dist[i]);
  ans -= mx;
  cout << ans;
}
