#include <bits/stdc++.h>
using namespace std;
const int maxn = 100002;
int n;
double ans;
int val[maxn];
int size[maxn];
int weight[maxn];
vector<pair<int, int> > g[maxn];
vector<int> son[maxn];
void helper(int cur, int pre) {
  size[cur] = 1;
  for (int i = 0; i < g[cur].size(); ++i)
    if (g[cur][i].first != pre) {
      int v = g[cur][i].first;
      int w = g[cur][i].second;
      helper(v, cur);
      son[cur].push_back(v);
      val[v] = w;
      size[cur] += size[v];
      weight[v] += w;
      weight[cur] += weight[v];
    }
}
bool cmp(const int a, const int b) {
  return 1.0 * weight[a] / size[a] < 1.0 * weight[b] / size[b];
}
void dfs(int cur) {
  int sum = 0;
  for (int i = 0; i < son[cur].size(); ++i) {
    int v = son[cur][i];
    sum += size[v];
    ans += size[v] * val[v];
    ans += 2.0 * (size[cur] - sum - 1) * weight[v];
    dfs(v);
  }
}
int main() {
  cin >> n;
  for (int i = 1; i < n; ++i) {
    int x, y, z;
    cin >> x >> y >> z;
    g[x].push_back(make_pair(y, z));
    g[y].push_back(make_pair(x, z));
  }
  helper(1, 0);
  for (int i = 1; i <= n; ++i) sort(son[i].begin(), son[i].end(), cmp);
  dfs(1);
  ans /= n - 1;
  printf("%.7f\n", ans);
  return 0;
}
