#include <bits/stdc++.h>
using namespace std;
const int N = 3e5;
vector<pair<long long, long long> > adj[N];
long long n;
long long dfs(long long node, long long par) {
  long long ans = 0;
  for (int i = 0; i < adj[node].size(); i++) {
    long long nn = adj[node][i].first;
    long long ncost = adj[node][i].second;
    if (nn == par) continue;
    ans += dfs(nn, node) + ncost;
  }
  return ans;
}
long long wtf(long long node, long long par) {
  long long besrot = 0;
  for (int i = 0; i < adj[node].size(); i++) {
    long long nn = adj[node][i].first;
    long long ncost = adj[node][i].second;
    if (nn == par) continue;
    long long q = wtf(nn, node) + ncost;
    besrot = max(besrot, q);
  }
  return besrot;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 0; i < n - 1; ++i) {
    long long y, x, z;
    cin >> x >> y >> z;
    adj[x].push_back({y, z});
    adj[y].push_back({x, z});
  }
  long long ans = 2 * dfs(1, 0);
  long long besrot = wtf(1, 0);
  cout << ans - besrot << endl;
  return 0;
}
