#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e18;
const long long SIZE = 1e5 + 5;
const long long mod = 1e9 + 7;
vector<pair<long long, long long> > adj[SIZE];
vector<long long> dis(SIZE, INF);
long long par[SIZE];
bool marked[SIZE];
long long ans;
void dijkstra() {
  dis[1] = 0;
  priority_queue<pair<long long, long long>,
                 vector<pair<long long, long long> >,
                 greater<pair<long long, long long> > >
      pq;
  pq.push(make_pair(dis[1], 1));
  par[1] = 1;
  long long u, v, w, i;
  while (!pq.empty()) {
    u = pq.top().second;
    pq.pop();
    for (i = 0; i < adj[u].size(); i++) {
      v = adj[u][i].first;
      w = adj[u][i].second;
      if (dis[v] > (dis[u] + w)) {
        dis[v] = dis[u] + w;
        par[v] = u;
        pq.push(make_pair(dis[v], v));
      }
    }
  }
}
void dfs(long long u, long long p) {
  long long v, w, i;
  for (i = 0; i < adj[u].size(); i++) {
    v = adj[u][i].first;
    w = adj[u][i].second;
    if (v == p) continue;
    if (!marked[v])
      ans += (2 * w);
    else
      ans += w;
    dfs(v, u);
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long t = 0, n, x, y, z, i, j, k, g, p, q, sum = 0, c = 0;
  cin >> n;
  for (i = 1; i <= n - 1; i++) {
    cin >> x >> y >> z;
    adj[x].push_back(make_pair(y, z));
    adj[y].push_back(make_pair(x, z));
  }
  dijkstra();
  for (i = 1; i <= n; i++) {
    if (dis[i] > c) {
      c = dis[i];
      p = i;
    }
  }
  while (par[p] != p) {
    marked[p] = 1;
    p = par[p];
  }
  dfs(1, 1);
  printf("%lld\n", ans);
  return 0;
}
