#include <bits/stdc++.h>
using namespace std;
const int inf = 2000000000;
const int N = 100005;
vector<pair<int, int> > g[N];
int s[N], t[N], T[N];
double dp[N];
bool cmp(int i, int j) {
  long long T1 = T[i];
  long long T2 = T[j];
  long long k1 = s[i];
  long long k2 = s[j];
  return k2 * T1 < k1 * T2;
}
void dfs(int v, int pr = -1) {
  s[v] = 0;
  T[v] = 0;
  dp[v] = 0;
  vector<int> a;
  for (int i = 0; i < g[v].size(); i++) {
    pair<int, int> to = g[v][i];
    if (to.first == pr) {
      continue;
    }
    dfs(to.first, v);
    s[v] += s[to.first];
    T[to.first] += 2 * to.second;
    T[v] += T[to.first];
    dp[to.first] *= (s[to.first] - 1);
    dp[to.first] += to.second * s[to.first];
    dp[to.first] /= s[to.first];
    a.push_back(to.first);
  }
  sort((a).begin(), (a).end(), cmp);
  long long all = 0;
  for (int i = 0; i < a.size(); i++) {
    int to = a[i];
    if (to == pr) {
      continue;
    }
    dp[v] += s[to] * dp[to] + s[to] * all;
    all += T[to];
  }
  if (s[v]) dp[v] /= s[v];
  s[v]++;
}
int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  int n;
  cin >> n;
  for (int i = 0; i < n - 1; i++) {
    int q, w, e;
    cin >> q >> w >> e;
    g[q].push_back(make_pair(w, e));
    g[w].push_back(make_pair(q, e));
  }
  dfs(1);
  cout << fixed << dp[1];
}
