#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
using namespace std;
const int N=100005;
int n;
struct edge{
int x,y,L;edge *next;
edge(int x,int y,int L,edge *next):x(x),y(y),L(L),next(next){}
}*ls[N];
int cnt;
int Size[N];
long long Sum[N];
vector <int> QQ[N];
bool cmp(int x,int y){
return Size[y]*Sum[x]<Size[x]*Sum[y];
}
long long dfs(int p,int fa){
long long ret=0;
vector <int> &Q=QQ[p];
Q.clear();
Size[p]=cnt++;
Sum[p]=0;
for (edge *t=ls[p];t;t=t->next)
if (t->y!=fa){
ret+=dfs(t->y,p);
ret+=t->L*Size[t->y];
Q.push_back(t->y);
Sum[p]+=Sum[t->y]+t->L*2;
Sum[t->y]+=t->L*2;
}
if (!Q.empty()){
sort(Q.begin(),Q.end(),cmp);
long long tmp=0;
for (int i=1;i<Q.size();i++){
tmp+=Sum[Q[i-1]];
ret+=tmp*Size[Q[i]];
}
}
Size[p]=cnt-Size[p];
return ret;
}
int main(){
scanf("%d",&n);
for (int i=1;i<n;i++){
int x,y,L;
scanf("%d%d%d",&x,&y,&L);
ls[x]=new edge(x,y,L,ls[x]);
ls[y]=new edge(y,x,L,ls[y]);
}
cout << fixed << setprecision(10) << 1.0*dfs(1,0)/(n-1) << endl;
}
I2luY2x1ZGUgPGNzdGRpbz4KI2luY2x1ZGUgPGNzdHJpbmc+CiNpbmNsdWRlIDxpb3N0cmVhbT4KI2luY2x1ZGUgPGFsZ29yaXRobT4KI2luY2x1ZGUgPHZlY3Rvcj4KI2luY2x1ZGUgPGlvbWFuaXA+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CmNvbnN0IGludCBOPTEwMDAwNTsKaW50IG47CnN0cnVjdCBlZGdlewogICAgICAgaW50IHgseSxMO2VkZ2UgKm5leHQ7CiAgICAgICBlZGdlKGludCB4LGludCB5LGludCBMLGVkZ2UgKm5leHQpOngoeCkseSh5KSxMKEwpLG5leHQobmV4dCl7fQp9KmxzW05dOwppbnQgY250OwppbnQgU2l6ZVtOXTsKbG9uZyBsb25nIFN1bVtOXTsKdmVjdG9yIDxpbnQ+IFFRW05dOwoKYm9vbCBjbXAoaW50IHgsaW50IHkpewogICAgIHJldHVybiBTaXplW3ldKlN1bVt4XTxTaXplW3hdKlN1bVt5XTsKfQoKbG9uZyBsb25nIGRmcyhpbnQgcCxpbnQgZmEpewogICAgIGxvbmcgbG9uZyByZXQ9MDsKICAgICB2ZWN0b3IgPGludD4gJlE9UVFbcF07CiAgICAgUS5jbGVhcigpOwogICAgIFNpemVbcF09Y250Kys7CiAgICAgU3VtW3BdPTA7CiAgICAgZm9yIChlZGdlICp0PWxzW3BdO3Q7dD10LT5uZXh0KQogICAgICAgICBpZiAodC0+eSE9ZmEpewogICAgICAgICAgICByZXQrPWRmcyh0LT55LHApOwogICAgICAgICAgICByZXQrPXQtPkwqU2l6ZVt0LT55XTsKICAgICAgICAgICAgUS5wdXNoX2JhY2sodC0+eSk7CiAgICAgICAgICAgIFN1bVtwXSs9U3VtW3QtPnldK3QtPkwqMjsKICAgICAgICAgICAgU3VtW3QtPnldKz10LT5MKjI7CiAgICAgICAgIH0KICAgICBpZiAoIVEuZW1wdHkoKSl7CiAgICAgICAgICBzb3J0KFEuYmVnaW4oKSxRLmVuZCgpLGNtcCk7CiAgICAgICAgICBsb25nIGxvbmcgdG1wPTA7CiAgICAgICAgICBmb3IgKGludCBpPTE7aTxRLnNpemUoKTtpKyspewogICAgICAgICAgICAgIHRtcCs9U3VtW1FbaS0xXV07CiAgICAgICAgICAgICAgcmV0Kz10bXAqU2l6ZVtRW2ldXTsKICAgICAgICAgIH0KICAgICB9CiAgICAgU2l6ZVtwXT1jbnQtU2l6ZVtwXTsKICAgICByZXR1cm4gcmV0Owp9CgppbnQgbWFpbigpewogICAgc2NhbmYoIiVkIiwmbik7CiAgICBmb3IgKGludCBpPTE7aTxuO2krKyl7CiAgICAgICAgaW50IHgseSxMOwogICAgICAgIHNjYW5mKCIlZCVkJWQiLCZ4LCZ5LCZMKTsKICAgICAgICBsc1t4XT1uZXcgZWRnZSh4LHksTCxsc1t4XSk7CiAgICAgICAgbHNbeV09bmV3IGVkZ2UoeSx4LEwsbHNbeV0pOwogICAgfQogICAgY291dCA8PCBmaXhlZCA8PCBzZXRwcmVjaXNpb24oMTApIDw8IDEuMCpkZnMoMSwwKS8obi0xKSA8PCBlbmRsOwp9