#include <bits/stdc++.h>
using namespace std;
const int N = 4e5 + 10;
int to[N], nxt[N], cur[N], res[N];
int n, w[N], num[N], val[N], h;
vector<int> E[N];
double ans;
void add(int u, int v, int c) {
  cur[h] = v;
  res[h] = c;
  nxt[h] = to[u];
  to[u] = h++;
}
bool cmp(int a, int b) { return 1LL * w[a] * num[b] < 1LL * w[b] * num[a]; }
void dfs(int u, int fa) {
  num[u] = 1;
  w[u] = 0;
  for (int i = to[u]; ~i; i = nxt[i]) {
    int v = cur[i];
    int c = res[i];
    if (v == fa) continue;
    dfs(v, u);
    E[u].push_back(v);
    num[u] += num[v];
    val[v] = c;
    w[v] += c;
    w[u] += w[v];
  }
}
void dfs2(int u) {
  int cnt = 0;
  for (int i = 0; i < E[u].size(); ++i) {
    int v = E[u][i];
    cnt = cnt + num[v];
    ans += num[v] * val[v];
    ans += 1LL * (num[u] - cnt - 1) * 2 * w[v];
    dfs2(v);
  }
}
int main() {
  cin >> n;
  memset(to, -1, sizeof to);
  h = 0;
  for (int i = 1; i < n; ++i) {
    int x, y, c;
    cin >> x >> y >> c;
    add(x, y, c);
    add(y, x, c);
  }
  dfs(1, -1);
  for (int i = 1; i <= n; ++i) sort(E[i].begin(), E[i].end(), cmp);
  dfs2(1);
  printf("%.12lf\n", ans / (n - 1));
  return 0;
}
