#include <bits/stdc++.h>
using namespace std;
int a[1000], s[1000], f[1000];
double d[1000];
void qs(int q, int w) {
  int e = q, r = w, t = f[q + (rand() % (w - q + 1))], y;
  double u;
  do {
    while (f[e] < t) e++;
    while (f[r] > t) r--;
    if (e <= r) {
      y = a[e];
      a[e] = a[r];
      a[r] = y;
      y = s[e];
      s[e] = s[r];
      s[r] = y;
      y = f[e];
      f[e] = f[r];
      f[r] = y;
      u = d[e];
      d[e] = d[r];
      d[r] = u;
      e++;
      r--;
    }
  } while (e <= r);
  if (q < r) qs(q, r);
  if (e < w) qs(e, w);
}
int main() {
  int q, w, e;
  double t = 0, r;
  cin >> q;
  for (w = 0; w < q; w++) cin >> a[w] >> s[w] >> f[w] >> d[w];
  qs(0, q - 1);
  for (w = 0; w < q; w++) {
    r = 0;
    for (e = 0; e < w; e++)
      if (sqrt((a[e] - a[w]) * (a[e] - a[w]) + (s[e] - s[w]) * (s[e] - s[w])) -
              f[w] + f[e] <
          0.0000001)
        r = max(r, d[e]);
    d[w] += r;
    t = max(t, d[w]);
  }
  cout << (int)t << ".";
  for (w = 0; w < 7; w++) {
    t -= (int)t;
    t *= 10;
    cout << (int)t;
  }
  return 0;
}
