#include <bits/stdc++.h>
using namespace std;
const int MAX_L = 20;
const long long MOD = 1e9 + 7;
const long long INF = 1e9 + 7;
int p = 100000007;
template <typename T>
void scan(T &x) {
  x = 0;
  bool neg = 0;
  register T c = getchar();
  if (c == '-') neg = 1, c = getchar();
  while ((c < 48) || (c > 57)) c = getchar();
  for (; c < 48 || c > 57; c = getchar())
    ;
  for (; c > 47 && c < 58; c = getchar()) x = (x << 3) + (x << 1) + (c & 15);
  if (neg) x *= -1;
}
template <typename T>
void print(T n) {
  bool neg = 0;
  if (n < 0) n *= -1, neg = 1;
  char snum[65];
  long long int i = 0;
  do {
    snum[i++] = n % 10 + '0';
    n /= 10;
  } while (n);
  --i;
  if (neg) putchar('-');
  while (i >= 0) putchar(snum[i--]);
  putchar('\n');
}
bool semiprime(long long int num) {
  int cnt = 0;
  for (int i = 2; cnt < 2 && i * i <= num; ++i)
    while (num % i == 0) num /= i, ++cnt;
  if (num > 1) ++cnt;
  return cnt == 2;
}
bool prime(long long int n) {
  if (n <= 1) return false;
  if (n <= 3) return true;
  if (n % 2 == 0 || n % 3 == 0) return false;
  for (int i = 5; i * i <= n; i = i + 6)
    if (n % i == 0 || n % (i + 2) == 0) return false;
  return true;
}
vector<pair<long long int, long long int>> g[100001];
long long int dfs(long long int nod, long long int y) {
  long long int ret = 0;
  for (auto x : g[nod]) {
    if (x.first != y) {
      ret = max(ret, x.second + dfs(x.first, nod));
    }
  }
  return ret;
}
void overpower() {
  long long int n, x, y, z;
  long long int tot = 0;
  cin >> n;
  for (int i = 0; i < n - 1; i++) {
    cin >> x >> y >> z;
    g[x].push_back(make_pair(y, z));
    g[y].push_back(make_pair(x, z));
    tot += 2 * z;
  }
  cout << tot - dfs(1, 0);
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  long long int t;
  t = 1;
  long long int i;
  for (long long int i = i = 0; i < t; i++) {
    overpower();
  }
}
