#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 228;
vector<pair<long long, long long> > g[maxn];
vector<bool> vis(maxn);
vector<long long> dis(maxn);
long long ans1;
int n;
void dfs(int v) {
  vis[v] = 1;
  for (int i = 0; i < g[v].size(); i++) {
    int to = g[v][i].second;
    long long mass = g[v][i].first;
    if (vis[to] == 0) {
      dis[to] = dis[v] + mass;
      dfs(to);
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0), cout.tie(0);
  cin >> n;
  for (int i = 0; i < n - 1; i++) {
    int x, y;
    long long w;
    cin >> x >> y >> w;
    x--;
    y--;
    g[x].push_back({w, y});
    g[y].push_back({w, x});
    ans1 += w;
  }
  ans1 *= 2;
  for (int i = 0; i < n; i++) {
    if (g[i].size() != 0) {
      sort(g[i].begin(), g[i].end());
    }
  }
  dfs(0);
  long long mx = 0;
  for (int i = 0; i < n; i++) {
    mx = max(mx, dis[i]);
  }
  cout << ans1 - mx;
  return 0;
}
