#include <bits/stdc++.h>
using namespace std;
const int MAX_INT = -1u >> 1;
const int N = 1000 + 10;
struct target {
  int x;
  int y;
  int t;
  double p;
  bool operator<(const target &other) const { return t < other.t; }
};
target a[N];
double dp[N];
bool Reachable(target u, target v) {
  return (long long)(u.x - v.x) * (u.x - v.x) + (u.y - v.y) * (u.y - v.y) <=
         ((long long)v.t - u.t) * (v.t - u.t);
}
int main() {
  int n;
  while (scanf("%d", &n) != EOF) {
    for (int i = 0; i < n; ++i) {
      scanf("%d%d%d%lf", &a[i].x, &a[i].y, &a[i].t, &a[i].p);
    }
    sort(a, a + n);
    for (int i = 0; i < n; ++i) dp[i] = a[i].p;
    for (int i = 0; i < n; ++i) {
      for (int j = 0; j < i; ++j) {
        if (Reachable(a[j], a[i]) && dp[j] + a[i].p > dp[i])
          dp[i] = dp[j] + a[i].p;
      }
    }
    double ans = 0;
    for (int i = 0; i < n; ++i)
      if (dp[i] > ans) ans = dp[i];
    printf("%lf\n", ans);
  }
  return 0;
}
