#include <bits/stdc++.h>
using namespace std;
const int N = 100010;
int n;
vector<pair<int, int>> son[N];
int size[N], edge[N];
void dfs(int x, int father) {
  size[x] = 1;
  for (vector<pair<int, int>>::iterator i = son[x].begin(); i != son[x].end();
       ++i) {
    int y = i->first;
    if (y == father) {
      i = son[x].erase(i);
      --i;
      continue;
    }
    edge[y] = i->second, dfs(y, x);
    size[x] += size[y], edge[x] += edge[y];
  }
  sort(son[x].begin(), son[x].end(), [](pair<int, int> X, pair<int, int> Y) {
    int x = X.first, y = Y.first;
    return (double)(edge[x]) / size[x] < (double)(edge[y]) / size[y];
  });
}
double ans = 0, sumt = 0;
void solve(int x) {
  ans += sumt / (n - 1);
  for (auto &e : son[x]) {
    sumt += e.second;
    solve(e.first);
    sumt += e.second;
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 1, x, y, w; i < n; ++i) {
    scanf("%d %d %d", &x, &y, &w);
    son[x].push_back(make_pair(y, w)), son[y].push_back(make_pair(x, w));
  }
  dfs(1, 0);
  solve(1);
  printf("%.8lf\n", ans);
}
