#include <bits/stdc++.h>
using namespace std;
const int nsz = 1e5;
int n, rt = 1, cur, sum[nsz + 5], sz[nsz + 5];
double ans;
vector<pair<int, int>> g[nsz + 5];
bool inline cmp(pair<int, int> a, pair<int, int> b) {
  return (long long)sz[b.first] * (sum[a.first]) <
         (long long)sz[a.first] * (sum[b.first]);
}
void dfs1(int u = rt, int p = -1, int w = 0) {
  sz[u] = 1;
  sum[u] = w;
  for (int i = 0; i < g[u].size(); ++i) {
    int v = g[u][i].first, w = g[u][i].second;
    if (v == p) continue;
    dfs1(v, u, w);
    sz[u] += sz[v];
    sum[u] += sum[v];
  }
}
void dfs2(int u = rt, int p = -1, int w = 0) {
  cur += w;
  sum[u] = cur;
  for (int i = 0; i < g[u].size(); ++i) {
    int v = g[u][i].first, w = g[u][i].second;
    if (v == p) continue;
    dfs2(v, u, w);
  }
  cur += w;
}
int inline read() {
  int res = 0;
  char c = getchar();
  for (; !isdigit(c); c = getchar())
    ;
  for (; isdigit(c); res *= 10, res += c ^ 48, c = getchar())
    ;
  return res;
}
int main() {
  ios_base::sync_with_stdio(0);
  n = read();
  for (int i = 1; i <= n - 1; ++i) {
    int u = read(), v = read(), w = read();
    g[u].push_back({v, w});
    g[v].push_back({u, w});
  }
  dfs1();
  for (int u = 1; u <= n; ++u) {
    sort(g[u].begin(), g[u].end(), cmp);
  }
  dfs2();
  for (int u = 1; u <= n; ++u) {
    ans += sum[u];
  }
  ans /= (n - 1);
  cout << fixed << setprecision(8) << ans << '\n';
}
