#include <bits/stdc++.h>
using namespace std;
vector<long long> adj[200000];
queue<long long> qu;
long long parent[200000], N, a[100000], b[100000], dist_p[100000], dist[100000];
long long p, q, w[100000], ans, M;
int main() {
  scanf("%I64d", &N);
  for (int i = 0; i < N - 1; i++) {
    scanf("%I64d %I64d %I64d", &a[i], &b[i], &w[i]);
    adj[a[i] - 1].push_back(b[i] - 1);
    adj[b[i] - 1].push_back(a[i] - 1);
  }
  for (int i = 0; i < N; i++) {
    parent[i] = -2;
  }
  parent[0] = -1;
  qu.push(0);
  while (qu.empty() == 0) {
    p = qu.front();
    qu.pop();
    for (int i = 0; i < adj[p].size(); i++) {
      q = adj[p][i];
      if (parent[q] == -2) {
        qu.push(q);
        parent[q] = p;
      }
    }
  }
  dist_p[0] = -1;
  for (int i = 0; i < N - 1; i++) {
    if (parent[a[i] - 1] == b[i] - 1) {
      dist_p[a[i] - 1] = w[i];
    } else {
      dist_p[b[i] - 1] = w[i];
    }
  }
  dist[0] = 0;
  qu.push(0);
  while (qu.empty() == 0) {
    p = qu.front();
    qu.pop();
    for (int i = 0; i < adj[p].size(); i++) {
      q = adj[p][i];
      if (parent[q] == p) {
        qu.push(q);
        dist[q] = dist[p] + dist_p[q];
      }
    }
  }
  M = 0;
  for (int i = 0; i < N; i++) {
    if (M < dist[i]) {
      M = dist[i];
    }
  }
  ans = 0;
  for (int i = 0; i < N - 1; i++) {
    ans = ans + 2 * w[i];
  }
  ans = ans - M;
  printf("%I64d\n", ans);
}
