#include <bits/stdc++.h>
using namespace std;
int n, Free[100007], p, deg[100007];
vector<pair<int, int> > AdjList[100007];
long long dis[100007], maxx, sum, total;
void input() {
  cin >> n;
  int x, y, w;
  total = 0;
  for (int i = 1; i <= n - 1; i++) {
    cin >> x >> y >> w;
    AdjList[x].push_back(make_pair(y, w));
    AdjList[y].push_back(make_pair(x, w));
    total += w;
  }
  for (int i = 1; i <= n; i++) Free[i] = 1;
}
void dfs(int u) {
  Free[u] = 0;
  for (int j = 0; j < (int)AdjList[u].size(); j++) {
    int v = AdjList[u][j].first;
    int price = AdjList[u][j].second;
    if (Free[v]) {
      dis[v] = dis[u] + price;
      dfs(v);
    }
  }
}
void process() {
  maxx = -1;
  dfs(1);
  for (int i = 1; i <= n; i++) {
    if (dis[i] > maxx) maxx = dis[i];
  }
  long long ans = 2 * total;
  ans = ans - maxx;
  printf("%I64d", ans);
}
int main() {
  input();
  if (n == 1) {
    cout << "0";
    return 0;
  }
  process();
  return 0;
}
