#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
vector<pair<int, int>> t[N];
int s[N];
long long g[N], f[N];
vector<int> q;
void dfs(int x, int y) {
  s[x] = 1;
  for (auto i : t[x]) {
    if (y == i.first) continue;
    g[i.first] = i.second;
    dfs(i.first, x);
    s[x] += s[i.first];
    g[x] += g[i.first];
    f[x] += f[i.first] + i.second * s[i.first];
  }
  for (auto i : t[x])
    if (y != i.first) q.push_back(i.first);
  sort(q.begin(), q.end(),
       [](int x, int y) { return s[y] * g[x] > s[x] * g[y]; });
  int w = 0;
  for (int i : q) f[x] += w * g[i] << 1, w += s[i];
  q.clear();
}
int main() {
  int n, x, y, z;
  scanf("%d", &n);
  for (int i = 1; i < n; ++i) {
    scanf("%d%d%d", &x, &y, &z);
    t[x].push_back(make_pair(y, z));
    t[y].push_back(make_pair(x, z));
  }
  dfs(1, 0);
  printf("%.8lf\n", 1.0 * f[1] / (n - 1));
  return 0;
}
