#include <bits/stdc++.h>
using namespace std;
vector<pair<int, long long> > g[100001];
int a, b, i, c, n;
long long d, sm;
long long dfs(int a, int b, long long d) {
  long long ret = d;
  for (int i = 0; i < g[a].size(); i++)
    if (g[a][i].first != b) {
      ret = max(ret, dfs(g[a][i].first, a, d + g[a][i].second));
    }
  return ret;
}
int main() {
  cin >> n;
  for (i = 1; i < n; i++) {
    cin >> a >> b >> c, --a, --b;
    g[a].push_back(make_pair(b, c));
    g[b].push_back(make_pair(a, c));
    sm += c;
  }
  cout << 2 * sm - dfs(0, -1, d);
  return 0;
}
