#include <bits/stdc++.h>
using namespace std;
long long n, a, b, c, ans, rmx, p[100005];
bool u[100005], r;
vector<pair<long long, long long> > g[100005];
vector<long long> t;
void dfs(int v) {
  u[v] = 1;
  r = 0;
  for (int i = 0; i < g[v].size(); ++i) {
    if (!u[g[v][i].first]) {
      r = 1;
      p[g[v][i].first] = p[v] + g[v][i].second;
      dfs(g[v][i].first);
    }
  }
  if (!r) {
    r = 1;
    t.push_back(v);
  }
}
int main() {
  scanf("%lld", &n);
  for (int i = 1; i < n; ++i) {
    scanf("%lld%lld%lld", &a, &b, &c);
    ans += (c * 2);
    g[a].push_back(make_pair(b, c));
    g[b].push_back(make_pair(a, c));
  }
  dfs(1);
  for (int i = 0; i < t.size(); ++i) rmx = max(rmx, p[t[i]]);
  printf("%lld", ans - rmx);
  return 0;
}
