#include <bits/stdc++.h>
using namespace std;
const long long inf = 1e18;
long long go[100100];
long long come[100100];
vector<pair<int, int> > graph[100100];
void dfs(int u, int p = -1) {
  int cnt = 0;
  for (int i = 0; i < graph[u].size(); i++) {
    int v = graph[u][i].first, w = graph[u][i].second;
    if (v == p) continue;
    cnt++;
    dfs(v, u);
    come[u] += come[v] + 2 * w;
  }
  if (cnt == 0) return;
  go[u] = inf;
  for (int i = 0; i < graph[u].size(); i++) {
    int v = graph[u][i].first, w = graph[u][i].second;
    if (v == p) continue;
    go[u] = min(go[u], come[u] - come[v] - w + go[v]);
  }
}
int main(void) {
  int n;
  scanf("%d", &n);
  for (int i = 1; i < n; i++) {
    int u, v, w;
    scanf("%d %d %d", &u, &v, &w);
    graph[u].push_back(make_pair(v, w));
    graph[v].push_back(make_pair(u, w));
  }
  dfs(1);
  printf("%lld\n", go[1]);
}
