#include <bits/stdc++.h>
using namespace std;
vector<int> g[2 * 100000 + 5];
vector<int> w[2 * 100000 + 5];
int par[2 * 100000 + 5];
signed long long int dfs(int v) {
  signed long long int ans = 0;
  for (int i = 0; i < g[v].size(); ++i) {
    int u = g[v][i];
    if (par[v] != u) {
      par[u] = v;
      ans = max(ans, w[v][i] + dfs(u));
    }
  }
  return ans;
}
int main() {
  int N, a, b, x;
  cin >> N;
  signed long long int T = 0;
  for (int i = 1; i < N; ++i) {
    scanf("%d", &a);
    scanf("%d", &b);
    scanf("%d", &x);
    g[a].push_back(b);
    g[b].push_back(a);
    w[a].push_back(x);
    w[b].push_back(x);
    T += 2 * x;
  }
  x = dfs(1);
  T -= x;
  cout << T;
}
