#include <bits/stdc++.h>
using namespace std;
int n, x, y, w;
vector<pair<int, int> > AdjList[100009];
long long DFS(int u, int p) {
  long long res = 0;
  for (int i = 0; i < (int)AdjList[u].size(); i++) {
    int v = AdjList[u][i].first;
    int cost = AdjList[u][i].second;
    if (v != p) res = max(res, DFS(v, u) + cost);
  }
  return res;
}
int main() {
  scanf("%d", &n);
  long long all = 0;
  for (int i = 0; i < n - 1; i++) {
    scanf("%d %d %d", &x, &y, &w);
    all += w;
    AdjList[x].push_back(make_pair(y, w));
    AdjList[y].push_back(make_pair(x, w));
  }
  all *= 2;
  long long res = DFS(1, -1);
  cout << all - res << '\n';
}
