#include <bits/stdc++.h>
using namespace std;
struct hedef {
  int x, y;
  double t, p;
};
hedef h[1005];
int n;
double dp[1005], cvp;
void oku() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++)
    scanf("%d %d %lf %lf", &h[i].x, &h[i].y, &h[i].t, &h[i].p);
  return;
}
bool cmp(hedef a, hedef b) { return a.t < b.t; }
void coz() {
  int i, j, fx, fy;
  sort(h + 1, h + n + 1, cmp);
  for (i = 1; i <= n; i++) {
    dp[i] = h[i].p;
    for (j = 1; j < i; j++) {
      fx = ((h[i].x - h[j].x) * (h[i].x - h[j].x));
      fy = ((h[i].y - h[j].y) * (h[i].y - h[j].y));
      if (h[j].t + sqrt(fx + fy) <= h[i].t + (1e-9))
        dp[i] = ((dp[i]) > (dp[j] + h[i].p) ? (dp[i]) : (dp[j] + h[i].p));
    }
    cvp = ((cvp) > (dp[i]) ? (cvp) : (dp[i]));
  }
  printf("%.10lf\n", cvp);
  return;
}
int main() {
  oku();
  coz();
  return 0;
}
