#include <bits/stdc++.h>
using namespace std;
long long n, a, b, c;
long long arp[200000];
vector<pair<long, long> > g[200000];
long long dist[200000];
long long s, bst;
void dfs(long v) {
  arp[v] = 1;
  for (int i = 0; i < g[v].size(); i++) {
    long q = g[v][i].first;
    if (arp[q] == 0) {
      arp[q] = 1;
      dist[q] = dist[v] + g[v][i].second;
      dfs(q);
    }
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin >> n;
  for (int i = 1; i < n; i++) {
    cin >> a >> b >> c;
    g[a].push_back(make_pair(b, c));
    g[b].push_back(make_pair(a, c));
    s += c;
    s += c;
  }
  dfs(1);
  bst = -1;
  for (int i = 1; i <= n; i++) bst = max(bst, dist[i]);
  cout << s - bst << endl;
  cin.get();
  cin.get();
  return 0;
}
