#include <bits/stdc++.h>
using namespace std;
const int M = 1000 + 10;
struct TARGET {
  int x;
  int y;
  int t;
  double p;
} target[M];
int cmp(const void *a, const void *b) {
  if ((*(struct TARGET *)a).t - (*(struct TARGET *)b).t < 0) {
    return -1;
  } else {
    return 1;
  }
}
double f[M];
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> target[i].x >> target[i].y >> target[i].t >> target[i].p;
  }
  qsort(target, n, sizeof(target[0]), cmp);
  f[0] = target[0].p;
  for (int i = 1; i < n; i++) {
    double max_p = target[i].p;
    for (int j = 0; j < i; j++) {
      double movetime =
          sqrt((target[j].x - target[i].x) * (target[j].x - target[i].x) +
               (target[j].y - target[i].y) * (target[j].y - target[i].y));
      if (movetime > 0 && movetime <= target[i].t - target[j].t) {
        if (f[j] + target[i].p > max_p) {
          max_p = f[j] + target[i].p;
        }
      }
    }
    f[i] = max_p;
  }
  double max_p = f[0];
  for (int i = 0; i < n; i++) {
    if (f[i] > max_p) {
      max_p = f[i];
    }
  }
  printf("%.10f", max_p);
  return 0;
}
