#include <bits/stdc++.h>
using namespace std;
const int maxn = 100010;
long long s[maxn], f[maxn];
int chd[maxn];
vector<pair<int, int> > g[maxn];
int n;
long long ans = 0;
bool cmp(pair<int, int> a, pair<int, int> b) {
  int u = a.first, v = b.first;
  return s[u] * chd[v] < s[v] * chd[u];
}
void dfs(int u, int pa) {
  chd[u] = 1;
  for (int i = 0; i < g[u].size(); ++i) {
    int v = g[u][i].first, c = g[u][i].second;
    if (v != pa) {
      s[v] = c * 2;
      dfs(v, u);
      s[u] += s[v];
      chd[u] += chd[v];
      f[v] += c * chd[v];
    }
  }
  sort(g[u].begin(), g[u].end(), cmp);
  long long sum = 0;
  for (int i = 0; i < g[u].size(); ++i) {
    int v = g[u][i].first, c = g[u][i].second;
    if (v != pa) {
      f[u] += f[v] + sum * chd[v];
      sum += s[v];
    }
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i < n; ++i) {
    int u, v, c;
    scanf("%d%d%d", &u, &v, &c);
    g[u].push_back(make_pair(v, c));
    g[v].push_back(make_pair(u, c));
  }
  dfs(1, 0);
  printf("%.15lf", 1.0 * f[1] / (n - 1));
  return 0;
}
