#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:102400000,102400000")
#pragma GCC optimize(2)
using namespace std;
const int maxn = 1e5 + 10;
int n;
int u[maxn], v[maxn];
vector<pair<int, int> > g[maxn];
long long dfs(int x, int fa = 0) {
  long long res = 0;
  for (auto cur : g[x]) {
    int v = cur.first, w = cur.second;
    if (v == fa) continue;
    res = max(res, dfs(v, x) + w);
  }
  return res;
}
void solve() {
  cin >> n;
  for (int i = 1; i <= n; ++i) g[i].clear();
  long long ans = 0;
  for (int w, i = 1; i < n; ++i) {
    cin >> u[i] >> v[i];
    cin >> w;
    g[u[i]].push_back({v[i], w});
    g[v[i]].push_back({u[i], w});
    ans += w;
  }
  ans <<= 1;
  ans -= dfs(1);
  cout << ans << endl;
}
int main() {
  solve();
  return 0;
}
