#include <bits/stdc++.h>
using namespace std;
vector<pair<long long int, long long int> > ad[100005];
bool vis[100005];
long long int dis[100005], trav = 0, mx = 0, mi;
void dfs(long long int u) {
  vis[u] = true;
  for (long long int i = 0; i < ad[u].size(); i++) {
    if (!vis[ad[u][i].first]) {
      trav += ad[u][i].second;
      dis[ad[u][i].first] = trav;
      if (mx < trav) {
        mx = trav;
        mi = ad[u][i].first;
      }
      dfs(ad[u][i].first);
      trav -= ad[u][i].second;
    }
  }
}
int main() {
  long long int n, a, b, w, sum = 0;
  cin >> n;
  for (long long int i = 0; i < n - 1; i++) {
    cin >> a >> b >> w;
    ad[a].push_back(make_pair(b, w));
    ad[b].push_back(make_pair(a, w));
    sum += w;
  }
  trav = 0;
  mx = 0;
  for (long long int i = 1; i <= n; i++) {
    vis[i] = false;
    dis[i] = 0;
  }
  dfs(1);
  cout << 2 * sum - mx << endl;
}
