#include <bits/stdc++.h>
using namespace std;
const int N = 1010;
struct node {
  double x;
  double y;
  double t;
  double p;
  bool operator<(const node& W) const { return t < W.t; }
} q[N];
double dp[N];
bool check(node a, node b) {
  double dx = a.x - b.x;
  double dy = a.y - b.y;
  return sqrt(dx * dx + dy * dy) <= b.t - a.t;
}
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> q[i].x >> q[i].y >> q[i].t >> q[i].p;
  }
  sort(q + 1, q + n + 1);
  dp[1] = q[1].p;
  for (int i = 2; i <= n; i++) {
    dp[i] = q[i].p;
    for (int j = 1; j <= i - 1; j++)
      if (check(q[j], q[i])) dp[i] = max(dp[i], dp[j] + q[i].p);
  }
  double res = 0;
  for (int i = 1; i <= n; i++) res = max(res, dp[i]);
  printf("%.6lf\n", res);
  return 0;
}
