#include <bits/stdc++.h>
using namespace std;
vector<pair<int, int>> v[100005];
bool vis[100005];
long long cost[100005];
long long solve(int x) {
  long long ans = 0;
  for (auto it : v[x])
    if (!vis[it.first])
      vis[it.first] = true, ans += solve(it.first) + it.second;
  return ans;
}
void traverse(int x, long long c) {
  cost[x] = c;
  for (auto it : v[x])
    if (!vis[it.first]) vis[it.first] = true, traverse(it.first, c + it.second);
}
int main() {
  int n, x, y, z;
  long long maxi = 0;
  cin >> n;
  vis[1] = true;
  for (int i = 1; i < n; i++)
    cin >> x >> y >> z, v[x].emplace_back(y, z), v[y].emplace_back(x, z);
  traverse(1, 0);
  for (int i = 2; i <= n; i++)
    if (v[i].size() == 1) maxi = max(maxi, cost[i]);
  memset(vis, false, sizeof vis);
  vis[1] = true;
  cout << solve(1) * 2 - maxi;
  return 0;
}
