#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 5;
int n, gra[maxn];
bool vis[maxn];
long long sum = 0;
vector<pair<int, int> > g[maxn];
void dfs(int u) {
  int len = g[u].size();
  for (int i = 0; i < len; i++) {
    int v = g[u][i].first;
    if (!vis[v]) {
      vis[v] = 1;
      gra[v] = gra[u] + g[u][i].second;
      dfs(v);
    }
  }
  return;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i < n; i++) {
    int x, y, w;
    scanf("%d%d%d", &x, &y, &w);
    g[x].push_back(make_pair(y, w));
    g[y].push_back(make_pair(x, w));
    sum += w;
  }
  vis[1] = 1;
  dfs(1);
  long long tmp = 0;
  for (int i = 1; i <= n; i++) {
    if (tmp < gra[i]) {
      tmp = gra[i];
    }
  }
  printf("%lld", sum * 2 - tmp);
  return 0;
}
