#include <bits/stdc++.h>
using namespace std;
void fastIO() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.precision(20);
}
long long A[100006];
long long B[100006];
long long C[100006];
long long Sum = 0;
long long Max = 0, Min = INT_MAX;
vector<long long> V[100006];
int visited[100006];
long long rev(long long a, long long b) { return a > b; }
void DFS(int source) {
  int u = source;
  visited[source] = 1;
  for (int i = 0; i < V[u].size(); i++) {
    int v = V[u][i];
    if (visited[v] == 0) {
      Sum += (A[v] * 2);
      B[v] += (B[u] + A[v]);
      Max = max(Max, B[v]);
      DFS(v);
    }
  }
}
int main() {
  fastIO();
  set<long long> S;
  set<long long>::iterator it;
  map<string, long long> M;
  map<string, long long>::iterator it1;
  long long a, b, c;
  long long n, m;
  long long cnt = 0, cntr = 0, sum = 0, ans = 1;
  long long p, q, r;
  long long v = 1;
  long long check = 0;
  long long x, y, z;
  string s, s1[100006], s2[100006], s3, s4;
  cin >> n;
  for (int i = 0; i < n - 1; i++) {
    cin >> a >> b >> x;
    V[a].push_back(b);
    V[b].push_back(a);
    A[max(a, b)] = x;
  }
  A[1] = 0;
  DFS(1);
  cout << Sum - Max << endl;
  return 0;
}
