#include <bits/stdc++.h>
using namespace std;
using lli = long long;
using ii = pair<long long, long long>;
using vi = vector<long long>;
using vvi = vector<vector<long long>>;
using vp = vector<pair<long long, long long>>;
long long mod = 1e9 + 7;
vector<vector<ii>> g;
lli par[100100];
lli ra[100100];
lli find(lli i) {
  if (i != par[i]) return par[i] = find(par[i]);
  return i;
}
void merge(lli x, lli y) {
  lli xr = find(x), yr = find(y);
  if (xr == yr) return;
  if (ra[xr] >= ra[yr]) {
    ra[xr] += ra[yr];
    par[yr] = xr;
  } else {
    ra[yr] += ra[xr];
    par[xr] = yr;
  }
}
long long dist[100100];
void dfs(long long node, long long par) {
  for (auto v : g[node]) {
    if ((v.first) != par) {
      dist[v.first] = min(dist[node] + v.second, dist[v.first]);
      dfs(v.first, node);
    }
  }
}
void solve() {
  long long n, x, y, w;
  cin >> n;
  g.resize(n + 1);
  vector<pair<long long, ii>> edges;
  for (long long i = 1; i <= n; i++) {
    par[i] = i;
    ra[i] = 1;
    dist[i] = 1e18;
  }
  for (long long i = 1; i < n; i++) {
    cin >> x >> y >> w;
    edges.push_back(make_pair(w, make_pair(x, y)));
  }
  sort(edges.begin(), edges.end());
  long long cost = 0;
  for (long long i = 0; i < (n - 1); i++) {
    if (find(edges[i].second.first) != find(edges[i].second.second)) {
      cost += edges[i].first;
      g[edges[i].second.first].push_back(
          make_pair(edges[i].second.second, edges[i].first));
      g[edges[i].second.second].push_back(
          make_pair(edges[i].second.first, edges[i].first));
      merge(edges[i].second.first, edges[i].second.second);
    }
  }
  dist[1] = 0;
  dfs(1, 0);
  long long res = 0;
  for (long long i = 2; i <= n; i++) {
    res = max(res, dist[i]);
  }
  cout << 2 * cost - res << "\n";
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long _t = 1;
  for (long long ix = 1; ix <= _t; ix++) solve();
  cerr << "Time Taken:" << (float)clock() / CLOCKS_PER_SEC << "secs" << endl;
}
