#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 6;
const int maxlog = 20;
const long long inf = 1e18;
const int mod = 1e9 + 7;
const long long base = 307;
vector<pair<long long, long long> > edge[maxn];
int dis[maxn];
int k;
void dfs(int v, int p) {
  k = max(dis[v], k);
  for (int i = 0; i < edge[v].size(); i++) {
    int u = edge[v][i].first;
    if (u != p) {
      dis[u] = dis[v] + edge[v][i].second;
      dfs(u, v);
    }
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  long long sum = 0;
  for (int i = 0; i < n - 1; i++) {
    int u, v, w;
    cin >> u >> v >> w;
    edge[u].push_back(make_pair(v, w));
    edge[v].push_back(make_pair(u, w));
    sum += (long long)w;
  }
  dfs(1, 0);
  cout << 2 * sum - (long long)k;
  return 0;
}
