#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5;
vector<long long> sum(MAXN), mn_sum(MAXN);
vector<vector<pair<int, int>>> g(MAXN);
void dfs0(int v, int prev) {
  sum[v] = 0;
  for (const auto& [to, weight] : g[v]) {
    if (to == prev) {
      continue;
    }
    dfs0(to, v);
    sum[v] += sum[to] + weight;
  }
}
void dfs1(int v, int prev) {
  mn_sum[v] = 0;
  int ind = -1;
  int ind_w;
  for (const auto& [to, weight] : g[v]) {
    if (to == prev) {
      continue;
    }
    dfs1(to, v);
    if (ind == -1 ||
        (sum[v] - weight - sum[to]) * 2 + weight + mn_sum[to] <
            (sum[v] - ind_w - sum[ind]) * 2 + ind_w + mn_sum[ind]) {
      ind = to;
      ind_w = weight;
    }
  }
  if (ind == -1) {
    return;
  }
  mn_sum[v] = (sum[v] - ind_w - sum[ind]) * 2 + ind_w + mn_sum[ind];
}
int main() {
  int n;
  cin >> n;
  for (int i = 1; i < n; ++i) {
    int x, y, w;
    cin >> x >> y >> w;
    --x;
    --y;
    g[x].emplace_back(y, w);
    g[y].emplace_back(x, w);
  }
  dfs0(0, -1);
  dfs1(0, -1);
  cout << mn_sum[0];
  return 0;
}
