#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
int n, cnt, Max, head[N];
struct Edge {
  int to, nxt, val;
} e[N << 1];
int read() {
  int x = 0, flg = 1;
  char c = getchar();
  for (; !isdigit(c); c = getchar())
    if (c == '-') flg = -1;
  for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
  return x * flg;
}
void add(int x, int y, int w) {
  e[++cnt].to = y;
  e[cnt].val = w;
  e[cnt].nxt = head[x];
  head[x] = cnt;
}
void dfs(int x, int fa, int dis) {
  Max = max(Max, dis);
  for (int i = head[x]; i; i = e[i].nxt) {
    int u = e[i].to;
    if (u == fa) continue;
    dfs(u, x, dis + e[i].val);
  }
}
int main() {
  n = read();
  int x, y, w;
  long long sum = 0;
  for (int i = 2; i <= n; ++i) {
    x = read(), y = read(), w = read();
    add(x, y, w);
    add(y, x, w);
    sum += 2 * w;
  }
  dfs(1, 0, 0);
  printf("%lld\n", sum - Max);
  return 0;
}
