#include<iostream>
#include<cstring>
#define maxn 50001
using namespace std;
struct node
{
int x,y;
int len;
};
node a[maxn];
int n,dis[maxn];
long long ans=0;
int main()
{
//freopen("tour.in.txt","r",stdin);
//freopen("tour.out.txt","w",stdout);
int MAX=0;
cin>>n;
for(int i=1;i<=n;i++)
dis[i]=100000;
for(int i=1;i<n;i++)
{
cin>>a[i].x>>a[i].y>>a[i].len;
ans+=a[i].len*2;
}
dis[1]=0;
//for(int i=1;i<=n;i++)
//cout<<"dis["<<i<<"]="<<dis[i]<<endl;
for(int o=1;o<=n;o++)
{
bool mt=false;
for(int i=1;i<=n;i++)
{
for(int j=1;j<=n;j++)
{
if(a[i].x==j&&dis[a[i].y]!=100000)
{
if(dis[j]>dis[a[i].y]+a[i].len)
{
dis[j]=dis[a[i].y]+a[i].len;
mt=true;
}
}
else if(a[i].y==j&&dis[a[i].x]!=100000)
{
if(dis[j]>dis[a[i].x]+a[i].len)
{
dis[j]=dis[a[i].x]+a[i].len;
mt=true;
}
}
}
}
if(!mt)
break;
}
for(int i=1;i<=n;i++)
{
//cout<<"dis["<<i<<"]="<<dis[i]<<endl;
if(dis[i]>MAX)
MAX=dis[i];
}
//cout<<"ans="<<ans<<" MAX="<<MAX<<endl;
cout<<ans-MAX<<endl;
return 0;
}