#include <bits/stdc++.h>
using namespace std;
vector<pair<long long, long long> > g[100005];
long long n, ans, ans2;
void dfs(long long u, long long p, long long cur) {
  ans2 = max(ans2, cur);
  for (auto e : g[u])
    if (e.first != p) dfs(e.first, u, cur + e.second);
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> n;
  for (long long i = 1; i <= n - 1; i++) {
    long long a, b, w;
    cin >> a >> b >> w;
    g[a].push_back({b, w});
    g[b].push_back({a, w});
    ans += w * 2;
  }
  dfs(1, 0, 0);
  cout << ans - ans2;
}
