#include <bits/stdc++.h>
using namespace std;
long long powmod(long long a, long long b) {
  long long res = 1;
  a %= 1000000007;
  for (; b; b >>= 1) {
    if (b & 1) res = res * a % 1000000007;
    a = a * a % 1000000007;
  }
  return res;
}
long long gcd(long long x, long long y) {
  while (y) {
    long long t = x % y;
    x = y;
    y = t;
  }
  return x;
}
template <typename T>
inline bool chkmin(T &a, const T &b) {
  return a > b ? a = b, 1 : 0;
}
template <typename T>
inline bool chkmax(T &a, const T &b) {
  return a < b ? a = b, 1 : 0;
}
unsigned int read() {
  unsigned int x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * f;
}
int fst[5000002], nxt[400100], vv[400100], e, cost[400100];
int n, fa[5000002], sz[5000002], tim[5000002];
long long ans[5000002];
vector<int> id[5000002];
bool cmp(int x, int y) { return 1LL * tim[x] * sz[y] < 1LL * tim[y] * sz[x]; }
void init() {
  e = 0;
  for (int i = 1; i <= n; i++) fst[i] = -1;
}
void add(int u, int v, int c) {
  vv[e] = v, nxt[e] = fst[u], cost[e] = c, fst[u] = e++;
}
void dfs(int u) {
  sz[u] = 1;
  tim[u] = 0;
  for (int i = fst[u]; ~i; i = nxt[i]) {
    int v = vv[i];
    if (v == fa[u]) continue;
    id[u].push_back(v);
    fa[v] = u;
    ans[v] = ans[u] + cost[i];
    dfs(v);
    sz[u] += sz[v];
    tim[v] += 2 * cost[i];
    tim[u] += tim[v];
  }
  sort(id[u].begin(), id[u].end(), cmp);
  long long now = 0;
  for (int i = 0; i < (int)id[u].size(); i++) {
    int v = id[u][i];
    ans[u] += ans[v] + now * sz[v];
    now += tim[v];
  }
}
int main() {
  n = read();
  init();
  for (int i = 1, u, v, c; i < n; i++) {
    u = read(), v = read(), c = read();
    add(u, v, c);
    add(v, u, c);
  }
  dfs(1);
  printf("%.10lf\n", 1.0 * ans[1] / (n - 1));
  return 0;
}
