#include <bits/stdc++.h>
using namespace std;
const int MAX = (int)1e5 + 2;
int dx[] = {1, 1, 0, -1, -1, -1, 0, 1};
int dy[] = {0, 1, 1, 1, 0, -1, -1, -1};
int vis[MAX];
long long ans = 0;
vector<vector<pair<int, int>>> edge(MAX);
int dfs(int i) {
  vis[i] = 1;
  int hold, maxx = 0;
  for (int j = 0; j < (int)edge[i].size(); j++) {
    if (vis[edge[i][j].first] == 0) {
      hold = edge[i][j].second;
      hold += dfs(edge[i][j].first);
      maxx = max(maxx, hold);
    }
  }
  return maxx;
}
int main() {
  int n, x, y, w;
  cin >> n;
  for (int i = 1; i < n; i++) {
    cin >> x >> y >> w;
    edge[x].push_back({y, w});
    edge[y].push_back({x, w});
    ans += 2 * w;
  }
  ans -= dfs(1);
  cout << ans << "\n";
  return 0;
}
