#include <bits/stdc++.h>
using namespace std;
void bfs(vector<pair<int, long long> >* graph, bool* used, long long* weights) {
  deque<int> d;
  d.push_back(0);
  weights[0] = 0;
  while (!d.empty()) {
    int cur = d.front();
    used[cur] = true;
    d.pop_front();
    for (int i = 0; i < graph[cur].size(); i++) {
      int checkVertex = graph[cur][i].first;
      long long checkWeight = graph[cur][i].second;
      if (!used[checkVertex]) {
        if (checkWeight == 0) {
          d.push_front(checkVertex);
          weights[checkVertex] = weights[cur];
        } else {
          d.push_back(checkVertex);
          weights[checkVertex] = weights[cur] + checkWeight;
        }
      }
    }
  }
}
int main() {
  ios ::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<pair<int, long long> >* graph = new vector<pair<int, long long> >[n];
  long long sum = 0;
  for (int i = 0; i < n - 1; i++) {
    int tmp1, tmp2;
    long long w;
    cin >> tmp1 >> tmp2 >> w;
    sum += w;
    tmp1--;
    tmp2--;
    graph[tmp1].push_back(make_pair(tmp2, w));
    graph[tmp2].push_back(make_pair(tmp1, w));
  }
  bool* used = new bool[n];
  long long* weights = new long long[n];
  for (int i = 0; i < n; i++) {
    used[i] = false;
  }
  vector<int> leafs;
  bfs(graph, used, weights);
  long long max = 0;
  for (int i = 0; i < n; i++) {
    max = weights[i] > max ? weights[i] : max;
  }
  cout << 2 * sum - max;
  return 0;
}
