#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
bool vis[N];
int n, par[N];
long long ans = 0;
vector<vector<pair<int, int>>> adj(N);
long long dfs(int node, int par) {
  long long ret = 0;
  for (int i = 0; i < adj[node].size(); i++) {
    int child = adj[node][i].first;
    int cost = adj[node][i].second;
    if (child != par) ret = max(ret, cost + dfs(child, node));
  }
  return ret;
}
int main() {
  long long ans = 0;
  cin >> n;
  for (int i = 0; i < n - 1; i++) {
    int u, v, w;
    cin >> u >> v >> w;
    ans += w;
    adj[u].push_back({v, w});
    adj[v].push_back({u, w});
  }
  ans *= 2;
  ans -= dfs(1, -1);
  cout << ans << endl;
  return 0;
}
