#include <bits/stdc++.h>
using namespace std;
map<pair<int, int>, int> wt;
long long dist[100005];
bool vis[100005];
vector<int> adj[100005], leaf;
int main() {
  int n, x, y, w, i, j, cur;
  long long ans = 0;
  cin >> n;
  for (i = 0; i < n - 1; i++) {
    cin >> x >> y >> w;
    adj[x].push_back(y);
    adj[y].push_back(x);
    wt[make_pair(x, y)] = w;
    wt[make_pair(y, x)] = w;
    ans += (2 * w);
  }
  queue<int> q;
  q.push(1);
  vis[1] = 1;
  dist[1] = 0;
  while (!q.empty()) {
    cur = q.front();
    q.pop();
    if (adj[cur].size() == 1) leaf.push_back(cur);
    for (i = 0; i < adj[cur].size(); i++) {
      if (!vis[adj[cur][i]]) {
        vis[adj[cur][i]] = 1;
        dist[adj[cur][i]] = dist[cur] + wt[make_pair(adj[cur][i], cur)];
        q.push(adj[cur][i]);
      }
    }
  }
  long long max_dist = 0;
  for (i = 0; i < leaf.size(); i++) {
    max_dist = max(max_dist, dist[leaf[i]]);
  }
  ans -= max_dist;
  cout << ans << endl;
  return 0;
}
