#include<bits/stdc++.h>
const int maxn=1e6;
inline const void read(int &a)
{
a=0;
char c=getchar();
while(c<'0'||c>'9')c=getchar();
while(c>='0'&&c<='9')
{
a=(a<<1)+(a<<3)+c-'0';
c=getchar();
}
}
inline const void write(int a)
{
if(a>=10)write(a/10);
putchar(a%10+'0');
}
class SIDE
{
public:
int from,to,len,next;
bool operator<(const SIDE&b)
{
if(len<b.len)return true;
else return false;
}
}s[maxn];
int n,ans=0,point[maxn],dis[maxn],son[maxn];
bool exist[maxn],wei[maxn];
inline const void add(int i)
{
s[i].next=point[s[i].from];
point[s[i].from]=i;
}
bool been[maxn];
void link_cut_tree(int p)
{
been[p]=true;
int side=point[p];
while(side)
{
if(!been[s[side].to])
{
link_cut_tree(s[side].to);
if(dis[s[side].to]+s[side].len>dis[p])
{
dis[p]=dis[s[side].to]+s[side].len;
son[p]=s[side].to;
}
}
side=s[side].next;
}
}
void dfs(int p)
{
if(wei[p])wei[son[p]]=true;
been[p]=true;
int side=point[p];
while(side)
{
if(!been[s[side].to])
{
ans+=s[side].len*2;
dfs(s[side].to);
if(wei[s[side].to])ans-=s[side].len;
}
side=s[side].next;
}
}
int main()
{
memset(wei,false,sizeof(wei));
memset(son,0,sizeof(son));
memset(dis,0,sizeof(dis));
memset(been,false,sizeof(been));
memset(point,0,sizeof(point));
read(n);
for(int i=1;i<=n-1;i++)
{
read(s[i].from);read(s[i].to);read(s[i].len);
add(i);
s[i+n-1].from=s[i].to;s[i+n-1].to=s[i].from;
s[i+n-1].len=s[i].len;exist[i+n-1]=exist[i];
add(i+n-1);
}
link_cut_tree(1);
memset(been,false,sizeof(been));
wei[1]=true;
dfs(1);
write(ans);
return 0;
}