#include <bits/stdc++.h>
using namespace std;
namespace IO {
const int maxn(1 << 21 | 1);
char ibuf[maxn], *iS, *iT, c;
int f;
inline char Getc() {
  return iS == iT ? (iT = (iS = ibuf) + fread(ibuf, 1, maxn, stdin),
                     (iS == iT ? EOF : *iS++))
                  : *iS++;
}
template <class Int>
inline void In(Int &x) {
  for (f = 1, c = Getc(); c < '0' || c > '9'; c = Getc()) f = c == '-' ? -1 : 1;
  for (x = 0; c >= '0' && c <= '9'; c = Getc())
    x = (x << 1) + (x << 3) + (c ^ 48);
  x *= f;
}
}  // namespace IO
using IO ::In;
const int maxn(1e5 + 5);
int n, first[maxn], cnt, son[maxn];
double f[maxn], sw[maxn], size[maxn];
struct Edge {
  int to, next, w;
} edge[maxn << 1];
inline void Add(int u, int v, int w) {
  edge[cnt] = (Edge){v, first[u], w}, first[u] = cnt++;
  edge[cnt] = (Edge){u, first[v], w}, first[v] = cnt++;
}
inline bool Cmp(int x, int y) { return sw[x] * size[y] < sw[y] * size[x]; }
void Dfs(int u, int ff) {
  size[u] = 1;
  for (int e = first[u], v; ~e; e = edge[e].next)
    if ((v = edge[e].to) != ff) {
      sw[v] += 2. * edge[e].w;
      Dfs(v, u);
      size[u] += size[v];
      f[v] += size[v] * edge[e].w, f[u] += f[v];
      sw[u] += sw[v];
    }
  int len = 0;
  for (int e = first[u], v; ~e; e = edge[e].next)
    if ((v = edge[e].to) != ff) son[++len] = v;
  sort(son + 1, son + len + 1, Cmp);
  double sz = size[u] - 1;
  for (int i = 1; i <= len; ++i) sz -= size[son[i]], f[u] += sw[son[i]] * sz;
}
int main() {
  memset(first, -1, sizeof(first));
  In(n);
  for (int i = 1, a, b, c; i < n; ++i) In(a), In(b), In(c), Add(a, b, c);
  Dfs(1, 0);
  printf("%.10lf\n", f[1] / (n - 1));
  return 0;
}
