#include <bits/stdc++.h>
using namespace std;
int N, A[100000];
long long ans = 0;
vector<pair<int, int> > T[100000];
void dfs(int v) {
  A[v] = 0;
  for (int i = 0; i < T[v].size(); i++)
    if (A[T[v][i].first] == -1) {
      dfs(T[v][i].first);
      A[v] = max(A[v], A[T[v][i].first] + T[v][i].second);
    }
}
int main() {
  scanf("%d", &N);
  memset(A, -1, sizeof(A));
  for (int v, u, w, i = 0; i < N - 1; i++) {
    scanf("%d %d %d", &v, &u, &w);
    --v;
    --u;
    T[v].push_back(make_pair(u, w));
    T[u].push_back(make_pair(v, w));
    ans += w;
  }
  dfs(0);
  printf("%I64d\n", 2 * ans - A[0]);
}
