#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("O3")
const int N = 1e5 + 9, M = 2e9, OO = 0x3f3f3f3f;
const long long int MOD = 1000000007;
const double PI = acos(-1);
vector<pair<int, int> > adj[N];
long long int Max = 0;
void dfs(int node, int prt, long long int sum) {
  for (auto child : adj[node]) {
    if (child.first != prt) {
      dfs(child.first, node, sum + child.second);
    }
    Max = max(Max, sum);
  }
}
int main() {
  long long int n, sum = 0;
  cin >> n;
  for (int i = 0; i < int(n - 1); ++i) {
    int x, y, z;
    cin >> x >> y >> z;
    adj[x].push_back({y, z});
    adj[y].push_back({x, z});
    sum += z;
  }
  dfs(1, 0, 0);
  cout << 2 * sum - Max;
}
