#include <bits/stdc++.h>
const int kMaxN = 100000;
std::vector<int> way[kMaxN], cost[kMaxN];
std::queue<int> queue;
int dist[kMaxN];
bool used[kMaxN];
int n;
int main() {
  int x, y, c;
  long long result = 0;
  scanf("%d", &n);
  for (int i = 1; i < n; ++i) {
    scanf("%d%d%d", &x, &y, &c);
    --x;
    --y;
    way[x].push_back(y);
    cost[x].push_back(c);
    way[y].push_back(x);
    cost[y].push_back(c);
    result += 2 * c;
  }
  memset(used, false, sizeof(used));
  used[0] = true;
  queue.push(0);
  while (!queue.empty()) {
    int u = queue.front();
    queue.pop();
    for (size_t i = 0; i < way[u].size(); ++i) {
      int v = way[u][i];
      if (used[v]) continue;
      used[v] = true;
      dist[v] = dist[u] + cost[u][i];
      queue.push(v);
    }
  }
  int max = 0;
  for (int i = 0; i < n; ++i) max = std::max(max, dist[i]);
  printf("%I64d\n", result - max);
  return 0;
}
