#include <bits/stdc++.h>
using namespace std;
struct edge {
  int v, w, next;
} edges[100010 << 1];
int head[100010], cnt;
int n;
long long dp[100010][2];
void init() {
  memset(head, -1, sizeof(head));
  memset(dp, 0x3f, sizeof(dp));
  cnt = 0;
}
void addedge(int u, int v, int w) {
  edges[cnt].v = v, edges[cnt].w = w, edges[cnt].next = head[u],
  head[u] = cnt++;
}
void dfs(int u, int fa) {
  dp[u][1] = 0;
  bool f = true;
  for (int i = head[u]; i != -1; i = edges[i].next) {
    int v = edges[i].v;
    if (v == fa) continue;
    f = false;
    dfs(v, u);
    dp[u][1] = dp[u][1] + dp[v][1] + 2 * edges[i].w;
  }
  if (f) {
    dp[u][0] = 0;
    return;
  }
  long long tmp;
  for (int i = head[u]; i != -1; i = edges[i].next) {
    int v = edges[i].v;
    if (v == fa) continue;
    tmp = dp[u][1] - dp[v][1] - 2 * edges[i].w;
    dp[u][0] = min(dp[u][0], tmp + edges[i].w + dp[v][0]);
  }
}
void solve() {
  dfs(1, 0);
  printf("%I64d\n", dp[1][0]);
}
int main(void) {
  while (~scanf("%d", &n)) {
    init();
    for (int i = 1; i < n; i++) {
      int u, v, w;
      scanf("%d%d%d", &u, &v, &w);
      addedge(u, v, w);
      addedge(v, u, w);
    }
    solve();
  }
  return 0;
}
