#include <bits/stdc++.h>
using namespace std;
struct pt {
  long long x, y, t;
  double p, exp;
} a[1005];
int N;
bool cmp(pt a, pt b) { return a.t < b.t; }
long long aabs(long long k) {
  if (k < 0)
    return -k;
  else
    return k;
}
long long d2(int i, int j) {
  return (long long)(a[i].x - a[j].x) * (a[i].x - a[j].x) +
         (long long)(a[i].y - a[j].y) * (a[i].y - a[j].y);
}
long long d1(int i, int j) {
  return aabs(a[i].x - a[j].x) + aabs(a[i].y - a[j].y);
}
int main() {
  scanf("%d", &N);
  for (int i = 0; i < N; ++i) {
    scanf("%I64d%I64d%I64d%lf", &a[i].x, &a[i].y, &a[i].t, &a[i].p);
    a[i].exp = a[i].p;
  }
  sort(a, a + N, cmp);
  for (int i = 0; i < N; ++i) {
    for (int j = 0; j < i; ++j) {
      if (a[i].t == a[j].t) continue;
      if (d2(i, j) <= ((long long)(a[j].t - a[i].t)) * (a[j].t - a[i].t)) {
        if (a[j].exp + a[i].p > a[i].exp) a[i].exp = a[j].exp + a[i].p;
      }
    }
  }
  double ans = a[0].exp;
  for (int i = 0; i < N; ++i) {
    if (ans < a[i].exp) ans = a[i].exp;
  }
  printf("%.10lf\n", ans);
  return 0;
}
