#include <bits/stdc++.h>
using namespace std;
struct pct {
  int x, y;
  long long t;
  double p;
} a[2010];
double maxim[2010], MAX;
int n, i, j;
bool cmp(pct a, pct b) { return a.t < b.t; }
long long dist2(int i, int j) {
  return (a[i].x - a[j].x) * (a[i].x - a[j].x) +
         (a[i].y - a[j].y) * (a[i].y - a[j].y);
}
int main() {
  cin >> n;
  for (i = 1; i <= n; i++) cin >> a[i].x >> a[i].y >> a[i].t >> a[i].p;
  sort(a + 1, a + n + 1, cmp);
  maxim[n] = a[n].p;
  MAX = maxim[n];
  for (i = n - 1; i >= 1; i--) {
    maxim[i] = 0.0;
    for (j = i + 1; j <= n; j++)
      if (dist2(i, j) <= (a[j].t - a[i].t) * (a[j].t - a[i].t))
        maxim[i] = maxim[i] > maxim[j] ? maxim[i] : maxim[j];
    maxim[i] += a[i].p;
    if (maxim[i] > MAX) MAX = maxim[i];
  }
  cout << fixed << setprecision(10) << MAX << '\n';
}
