#include <bits/stdc++.h>
using namespace std;
long long n, m;
vector<pair<long long, long long> > v[100900];
pair<long long, long long> DFS(long long now, long long fa, long long deep) {
  pair<long long, long long> ans = make_pair(deep, now);
  for (auto to : v[now])
    if (to.first != fa) {
      ans = max(ans, DFS(to.first, now, deep + to.second));
    }
  return ans;
}
int32_t main() {
  cin >> n;
  long long ans = 0;
  for (long long i = 2; i < n + 1; i++) {
    long long a, b, c;
    cin >> a >> b >> c;
    v[a].push_back(make_pair(b, c));
    v[b].push_back(make_pair(a, c));
    ans += c + c;
  }
  ans -= DFS(1, 0, 0).first;
  cout << ans << endl;
  return 0;
}
