#include <bits/stdc++.h>
using namespace std;
int res = 0;
vector<pair<long long, long long> > g[100020];
int n;
vector<long long> d;
bool was[100002];
bool isleaf[100002];
long long dist[100002];
long long total = 0ll;
void go(int x, long long sum) {
  was[x] = true;
  isleaf[x] = true;
  for (int i = 0; i < g[x].size(); i++) {
    if (!was[g[x][i].first]) {
      isleaf[x] = false;
      go(g[x][i].first, sum + g[x][i].second);
    }
  }
  if (isleaf[x]) {
    dist[x] = sum;
  }
}
int main() {
  cin >> n;
  for (int i = 0; i < n - 1; i++) {
    long long x, y, w;
    cin >> x >> y >> w;
    total += w;
    g[x].push_back(make_pair(y, w));
    g[y].push_back(make_pair(x, w));
  }
  go(1, 0ll);
  long long ans = 1000000000000000000ll;
  for (int i = 1; i <= n; i++) {
    if (isleaf[i]) {
      ans = min(ans, 2ll * total - dist[i]);
    }
  }
  cout << ans << endl;
  return 0;
}
