#include <bits/stdc++.h>
using namespace std;
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << " : " << arg1 << " | ";
  __f(comma + 1, args...);
}
const int N = 100011;
vector<pair<int, int> > gr[N];
int n;
long long int mx;
void dfs(int v, int p, int wt) {
  for (auto u : gr[v]) {
    if (u.first == p) continue;
    dfs(u.first, v, wt + u.second);
  }
  if (wt > mx) mx = wt;
}
int main() {
  scanf("%d", &n);
  long long int ans = 0;
  for (int i = 1; i < n; ++i) {
    int u, v, w;
    scanf("%d", &u), scanf("%d", &v), scanf("%d", &w);
    gr[u].push_back(make_pair(v, w));
    gr[v].push_back(make_pair(u, w));
    ans += 2 * w;
  }
  dfs(1, 0, 0);
  printf("%lld\n", ans - mx);
  return 0;
}
