#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1005;
int wsp[MAXN][2], t[MAXN], nr[MAXN];
double w[MAXN];
double p[MAXN];
bool cmp(int a, int b) { return t[a] < t[b]; }
int main() {
  int a, b, c, d, e, n;
  double x;
  scanf("%d", &n);
  for (a = 0; a < n; a++) {
    scanf("%d%d%d%lf", &wsp[a][0], &wsp[a][1], &t[a], &p[a]);
    nr[a] = a;
  }
  sort(nr, nr + n, cmp);
  for (a = 0; a < n; a++) {
    b = nr[a];
    for (c = 0; c < n; c++)
      if (c == b)
        w[b] = max(w[b], p[b]);
      else if ((long long)(t[b] - t[c]) * (t[b] - t[c]) >=
               (wsp[b][0] - wsp[c][0]) * (wsp[b][0] - wsp[c][0]) +
                   (wsp[b][1] - wsp[c][1]) * (wsp[b][1] - wsp[c][1]))
        w[b] = max(w[b], p[b] + w[c]);
  }
  x = 0;
  for (a = 0; a < n; a++) x = max(x, w[a]);
  printf("%.8lf", x);
  return 0;
}
