#include <bits/stdc++.h>
using ll = long long;
const int N = 1e5 + 9;
using namespace std;
int n, m, head[N], cnt = 0;
ll d[N];
bool vis[N];
struct Edge {
  int v, w, nxt;
} e[N << 1];
void ad(int u, int v, int w) {
  e[cnt].v = v;
  e[cnt].w = w;
  e[cnt].nxt = head[u];
  head[u] = cnt++;
}
void add(int u, int v, int w) {
  ad(u, v, w);
  ad(v, u, w);
}
void bfs(int s) {
  memset(d, 0x3f, sizeof d);
  memset(vis, 0, sizeof vis);
  priority_queue<pair<int, int> > q;
  d[s] = 0;
  q.push(make_pair(-d[s], s));
  while (!q.empty()) {
    pair<int, int> tp = q.top();
    q.pop();
    int u = tp.second;
    if (vis[u]) continue;
    vis[u] = 1;
    d[u] = -tp.first;
    for (int i = head[u]; ~i; i = e[i].nxt) {
      int v = e[i].v;
      if (d[u] + e[i].w < d[v]) {
        d[v] = d[u] + e[i].w;
        q.push(make_pair(-(d[v]), v));
      }
    }
  }
}
int main() {
  scanf("%d", &n);
  int u, v, w;
  ll ans = 0;
  memset(head, -1, sizeof head);
  for (int i = 1; i < n; i++) {
    scanf("%d%d%d", &u, &v, &w);
    add(u, v, w);
    ans += w;
  }
  bfs(1);
  ll tmp = 0;
  for (int i = 2; i <= n; i++) {
    tmp = max(tmp, d[i]);
  }
  printf("%lld\n", ans * 2 - tmp);
  return 0;
}
