#include <bits/stdc++.h>
using namespace std;
vector<int> g[100000];
vector<int> c[100000];
long long f(int pos, int prev) {
  long long ans = 0;
  for (int i = 0; i < g[pos].size(); i++)
    if (g[pos][i] != prev) ans = max(ans, f(g[pos][i], pos) + c[pos][i]);
  return ans;
}
int main() {
  long long sum = 0;
  int n;
  cin >> n;
  for (int i = 0; i < n - 1; i++) {
    int a, b, t;
    cin >> a >> b >> t;
    a--, b--;
    g[a].push_back(b);
    c[a].push_back(t);
    g[b].push_back(a);
    c[b].push_back(t);
    sum += 2 * t;
  }
  cout << sum - f(0, -1) << endl;
}
