#include <bits/stdc++.h>
using namespace std;
typedef struct node {
  int next;
  int cost;
} Gx;
vector<Gx> Graph[100010];
long long maxi(long long a, long long b) {
  if (a > b) return a;
  return b;
}
bool visited[100010];
long long dfs(int node) {
  long long res = 0;
  visited[node] = true;
  for (int i = 0; i < Graph[node].size(); i++) {
    if (!visited[(Graph[node][i].next)])
      res = maxi(res, dfs(Graph[node][i].next) + Graph[node][i].cost);
  }
  return res;
}
int main() {
  int x, y, c, N;
  long long res = 0;
  cin >> N;
  for (int i = 0; i < N; i++) {
    Graph[i].clear();
    visited[i] = false;
  }
  for (int i = 0; i < N - 1; i++) {
    cin >> x >> y >> c;
    Gx g;
    g.next = y - 1;
    g.cost = c;
    Graph[x - 1].push_back(g);
    g.next = x - 1;
    Graph[y - 1].push_back(g);
    res += c;
  }
  res = 2 * res - dfs(0);
  cout << res << "\n";
  return 0;
}
