#include <bits/stdc++.h>
#pragma comment(linker, "/stack:64000000")
using namespace std;
vector<vector<int> > v;
vector<vector<int> > c;
vector<bool> u;
long long dfs(int x) {
  u[x] = true;
  long long r = 0;
  for (int(i) = 0; (i) < ((int)(v[x]).size()); (i)++) {
    int to = v[x][i];
    if (!u[to]) {
      r = max(r, c[x][i] + dfs(to));
    }
  }
  return r;
}
int main() {
  int n, x, y, w;
  scanf("%d", &n);
  v.resize(n);
  c.resize(n);
  u.resize(n);
  long long res = 0;
  for (int(i) = 0; (i) < (n - 1); (i)++) {
    scanf("%d %d %d", &x, &y, &w);
    x--, y--;
    res += 2 * w;
    v[x].push_back(y);
    v[y].push_back(x);
    c[x].push_back(w);
    c[y].push_back(w);
  }
  cout << res - dfs(0);
  return 0;
}
