#include <bits/stdc++.h>
using namespace std;
long long n, d[100005];
vector<pair<long long, long long> > mp[100005];
long long dfs(long long x, long long f) {
  for (int i = 0; i < mp[x].size(); i++) {
    pair<long long, long long> q = mp[x][i];
    if (q.first == f) continue;
    dfs(q.first, x);
    d[x] = max(d[x], d[q.first] + q.second);
  }
  return d[x];
}
int main() {
  cin >> n;
  long long x, y, z;
  long long sum = 0;
  for (int i = 0; i < n - 1; i++) {
    cin >> x >> y >> z;
    mp[x].push_back(make_pair(y, z));
    mp[y].push_back(make_pair(x, z));
    sum += 2 * z;
  }
  long long w = dfs(1, -1);
  cout << sum - w;
}
