#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6 + 17;
const long long inf = 1e16;
vector<pair<int, int> > v[maxn];
long long bereobarnagarde[maxn], bereobargarde[maxn];
int flag[maxn];
inline void dfs(int x, int p) {
  int Min = 0;
  for (int i = 0; i < v[x].size(); i++)
    if (v[x][i].first != p) dfs(v[x][i].first, x);
  long long sum = 0;
  for (int i = 0; i < v[x].size(); i++)
    if (v[x][i].first != p)
      sum += bereobargarde[v[x][i].first] + 2 * v[x][i].second;
  bereobargarde[x] = sum;
  bereobarnagarde[x] = inf;
  for (int i = 0; i < v[x].size(); i++)
    if (v[x][i].first != p)
      bereobarnagarde[x] =
          min(bereobarnagarde[x], sum - 1LL * v[x][i].second -
                                      bereobargarde[v[x][i].first] +
                                      bereobarnagarde[v[x][i].first]);
  if (bereobarnagarde[x] == inf) bereobarnagarde[x] = 0;
}
int main() {
  ios_base::sync_with_stdio(false);
  int n;
  cin >> n;
  for (int i = 1; i < n; i++) {
    int x, y, w;
    cin >> x >> y >> w;
    v[x].push_back(pair<int, int>(y, w));
    v[y].push_back(pair<int, int>(x, w));
  }
  dfs(1, 0);
  cout << bereobarnagarde[1] << "\n";
}
