#include <bits/stdc++.h>
using namespace std;
vector<pair<int, int>> e[100001];
tuple<long long, long long, long long> gao(int x, int from) {
  tuple<long long, long long, long long> ret(1, 0, 0);
  vector<tuple<long long, long long, long long>> u;
  for (auto r : e[x]) {
    int y = r.first, c = r.second;
    if (y == from) continue;
    tuple<long long, long long, long long> o = gao(y, x);
    get<1>(o) += 2 * c;
    get<2>(o) += get<0>(o) * c;
    u.push_back(o);
  }
  sort(u.begin(), u.end(),
       [](tuple<long long, long long, long long> lhs,
          tuple<long long, long long, long long> rhs) {
         return get<1>(lhs) * get<0>(rhs) < get<1>(rhs) * get<0>(lhs);
       });
  for (auto r : u) {
    get<2>(ret) += get<2>(r) + get<1>(ret) * get<0>(r);
    get<0>(ret) += get<0>(r);
    get<1>(ret) += get<1>(r);
  }
  return ret;
}
int main() {
  int n, x, y, c;
  scanf("%d", &n);
  for (int i = 1; i < n; i++) {
    scanf("%d%d%d", &x, &y, &c);
    e[x].push_back({y, c});
    e[y].push_back({x, c});
  }
  tuple<long long, long long, long long> ret = gao(1, 0);
  printf("%.12f\n", get<2>(ret) / (get<0>(ret) - 1.0));
}
