#include <bits/stdc++.h>
using namespace std;
template <class T>
inline int size(T& n) {
  return n.size();
}
template <class T>
inline bool isPrime(T n) {
  if (n <= 1) return false;
  for (T i = 2; i * i <= n; i++)
    if (n % i == 0) return false;
  return true;
}
vector<pair<int, int> > edge[100002];
int City[100002];
long long N, x, y, z, tmp;
long long dfs_visit(int u) {
  City[u] = 1;
  long long ret = 0;
  for (int i = 0; i < edge[u].size(); ++i) {
    long long v = edge[u][i].first;
    long long c = edge[u][i].second;
    if (!City[v]) {
      tmp = dfs_visit(v);
      ret = max(ret, c + tmp);
    }
  }
  return ret;
}
long long dfs() {
  memset(City, 0, sizeof(City));
  return dfs_visit(1);
}
long long res;
int main() {
  cin >> N;
  for (int i = 1; i <= N - 1; ++i) edge[i].clear();
  for (int i = 1; i <= N - 1; ++i) {
    cin >> x >> y >> z;
    edge[x].push_back(pair<int, int>(y, z));
    edge[y].push_back(pair<int, int>(x, z));
    res += 2 * z;
  }
  res -= dfs();
  cout << res << endl;
}
