#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 100;
vector<pair<int, int> > e[N];
int dfs(int v, int p) {
  int ret = 0;
  for (auto it : e[v]) {
    int u = it.first, w = it.second;
    if (u == p) continue;
    int now = w + dfs(u, v);
    ret = max(ret, now);
  }
  return ret;
}
int main() {
  ios_base::sync_with_stdio(0);
  int n;
  cin >> n;
  long long ans = 0;
  for (int i = 0; i < n - 1; ++i) {
    int a, b, w;
    cin >> a >> b >> w;
    e[a].emplace_back(b, w);
    e[b].emplace_back(a, w);
    ans += 2 * w;
  }
  int p = dfs(1, -1);
  ans -= p;
  cout << ans << '\n';
}
