#include <bits/stdc++.h>
using namespace std;
const int maxn = 101111;
struct edge {
  int v, w, fail;
} e[maxn * 2];
int p[maxn], eid;
void init() {
  memset(p, -1, sizeof p);
  eid = 0;
}
void insert(int u, int v, int w) {
  e[eid].v = v;
  e[eid].w = w;
  e[eid].fail = p[u];
  p[u] = eid++;
}
int n, dis[maxn], fa[maxn], len[maxn], pb = 0, maxl = 0;
void dfs(int u, int f) {
  for (int i = p[u]; ~i; i = e[i].fail) {
    int v = e[i].v;
    int w = e[i].w;
    if (v == f) continue;
    fa[v] = u;
    len[v] = w;
    if (dis[v] < dis[u] + w) {
      dis[v] = dis[u] + w;
    }
    if (dis[v] > maxl) {
      maxl = dis[v];
      pb = v;
    }
    dfs(v, u);
  }
}
int main() {
  ios::sync_with_stdio(false);
  init();
  cin >> n;
  if (n == 1) {
    cout << 0 << endl;
    return 0;
  }
  long long ans = 0;
  for (int i = 1; i < n; i++) {
    int u, v, w;
    cin >> u >> v >> w;
    ans += w * 2;
    insert(u, v, w);
    insert(v, u, w);
  }
  dfs(1, 0);
  fa[0] = -1;
  int now = pb;
  while (now != 1 && now != 0 && now != -1) {
    ans -= len[now];
    now = fa[now];
  }
  cout << ans << endl;
  return 0;
}
