#include <bits/stdc++.h>
using namespace std;
struct s {
  long long x, y, t;
  double p;
};
s arr[1003];
double ans[1003];
bool cmp(s a, s b) { return a.t < b.t; }
int main() {
  long long n, i, j;
  double max1;
  cin >> n;
  for (i = 1; i <= n; i++) cin >> arr[i].x >> arr[i].y >> arr[i].t >> arr[i].p;
  sort(arr + 1, arr + n + 1, cmp);
  for (i = 1; i <= n; i++) {
    ans[i] = arr[i].p;
    for (j = 1; j < i; j++) {
      if ((arr[j].x - arr[i].x) * (arr[j].x - arr[i].x) +
              (arr[j].y - arr[i].y) * (arr[j].y - arr[i].y) <=
          (arr[i].t - arr[j].t) * (arr[i].t - arr[j].t)) {
        if (ans[j] + arr[i].p > ans[i]) ans[i] = ans[j] + arr[i].p;
      }
    }
  }
  max1 = 0.0;
  for (i = 1; i <= n; i++) {
    if (ans[i] > max1) max1 = ans[i];
  }
  printf("%.10lf\n", max1);
  return 0;
}
