#include <bits/stdc++.h>
using namespace std;
long long len[500500], sz[500500], f[500500];
int n, top, cnt = 1;
int head[500500], S[500500];
struct Line {
  int to, next, w;
} edge[500500 << 1];
void Add(int u, int v, int w) {
  edge[cnt] = (Line){v, head[u], w};
  head[u] = cnt++;
}
bool cmp(int a, int b) { return 1ll * sz[a] * len[b] > 1ll * sz[b] * len[a]; }
void dfs(int u, int ff) {
  sz[u] = 1;
  for (int i = head[u]; i; i = edge[i].next)
    if (edge[i].to != ff) {
      dfs(edge[i].to, u);
      len[u] += len[edge[i].to] + 2 * edge[i].w;
      sz[u] += sz[edge[i].to];
    }
  top = 0;
  long long s = 0;
  for (int i = head[u]; i; i = edge[i].next)
    if (edge[i].to != ff) {
      f[u] += f[edge[i].to] + 1ll * sz[edge[i].to] * edge[i].w;
      len[edge[i].to] += 2 * edge[i].w;
      S[++top] = edge[i].to;
    }
  sort(&S[1], &S[top + 1], cmp);
  for (int i = 1; i <= top; ++i) {
    f[u] += sz[S[i]] * s;
    s += len[S[i]];
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i < n; ++i) {
    int u, v, w;
    scanf("%d%d%d", &u, &v, &w);
    Add(u, v, w);
    Add(v, u, w);
  }
  dfs(1, 0);
  printf("%.10lf\n", 1.0 * f[1] / (n - 1));
  return 0;
}
