#include <bits/stdc++.h>
using namespace std;
int OO = 10000000;
int dr[] = {1, 1, 0, -1, -1, -1, 0, 1};
int dc[] = {0, 1, 1, 1, 0, -1, -1, -1};
vector<vector<pair<int, int> > > v(100005);
int dep[100005];
int mx = 0;
void dfs(int node) {
  mx = max(dep[node], mx);
  for (int i = 0; i < v[node].size(); i++) {
    if (!dep[v[node][i].first]) {
      dep[v[node][i].first] = v[node][i].second + dep[node];
      dfs(v[node][i].first);
    }
  }
}
int main() {
  ios::sync_with_stdio(0);
  memset(dep, 0, sizeof dep);
  int n;
  cin >> n;
  long long ans = 0;
  for (int i = 1; i < n; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    v[a].push_back(make_pair(b, c));
    v[b].push_back(make_pair(a, c));
    ans += c * 2;
  }
  dep[1] = 1;
  dfs(1);
  cout << ans - mx + 1;
}
