#include <bits/stdc++.h>
using namespace std;
vector<pair<int, int> > g[100100];
int vis, cost, n;
long long dfs(pair<int, int> node, int par) {
  long long ans = 0;
  for (pair<int, int> p : g[node.first]) {
    if (p.first == par) continue;
    long long c = dfs(p, node.first);
    ans = max(ans, c);
  }
  return ans + node.second;
}
int main() {
  int u, v, w;
  long long ans = 0;
  cin >> n;
  for (int i = 1; i < n; i++) {
    cin >> u >> v >> w;
    ans += w;
    g[u].push_back(pair<int, int>(v, w));
    g[v].push_back(pair<int, int>(u, w));
  }
  cout << 2 * ans - dfs(pair<int, int>(1, 0), 0) << endl;
}
