#include <bits/stdc++.h>
using namespace std;
int bl[100000];
int n;
long long mx;
long long DFS(vector<vector<pair<int, int> > >& G, int node) {
  bl[node] = 1;
  pair<int, int> tmp;
  int i;
  long long ans = 0, mx = 0, t2;
  for (i = 0; i < G[node].size(); i++) {
    tmp = G[node][i];
    if (bl[tmp.first] == 0) {
      t2 = (long long)tmp.second * 2ll + DFS(G, tmp.first);
      ans += t2;
    }
  }
  return ans;
}
long long DFS2(vector<vector<pair<int, int> > >& G, int node) {
  bl[node] = 1;
  pair<int, int> tmp;
  int i;
  long long mx = 0, t2;
  for (i = 0; i < G[node].size(); i++) {
    tmp = G[node][i];
    if (bl[tmp.first] == 0) {
      t2 = (long long)tmp.second + DFS2(G, tmp.first);
      mx = max(t2, mx);
    }
  }
  return mx;
}
int main() {
  vector<vector<pair<int, int> > > G;
  memset(bl, 0, sizeof(bl));
  int n, i, j, u, v, w;
  long long ans = 0, mx = 0, t2;
  scanf("%d", &n);
  G.resize(n);
  for (i = 0; i < n - 1; i++) {
    scanf("%d %d %d", &u, &v, &w);
    u--;
    v--;
    G[u].push_back(make_pair(v, w));
    G[v].push_back(make_pair(u, w));
    ans += 2ll * (long long)w;
  }
  memset(bl, 0, sizeof(bl));
  ans -= DFS2(G, 0);
  cout << ans << endl;
  return 0;
}
