#include <bits/stdc++.h>
using namespace std;
struct Tar {
  int x, y, t;
  double p;
  void read() { scanf("%d%d%d%lf", &x, &y, &t, &p); }
} r[1010];
bool cmp(Tar a, Tar b) { return a.t < b.t; }
double dis(double x, double y) { return sqrt(x * x + y * y); }
bool good(int a, int b) {
  return dis(r[a].x - r[b].x, r[a].y - r[b].y) < r[b].t - r[a].t + 1e-8;
}
double dp[1010];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) r[i].read();
  sort(r, r + n, cmp);
  dp[0] = r[0].p;
  for (int i = 1; i < n; i++) {
    dp[i] = r[i].p;
    for (int j = 0; j < i; j++) {
      if (good(j, i)) {
        dp[i] = max(dp[i], dp[j] + r[i].p);
      }
    }
  }
  double mx = 0;
  for (int i = 0; i < n; i++) mx = max(mx, dp[i]);
  printf("%.9lf\n", mx);
  return 0;
}
