#include <bits/stdc++.h>
using namespace std;
struct S {
  int x, y, t;
  double p;
  bool operator<(const S &r) const { return t < r.t; }
};
double dp[1000];
void run() {
  int n;
  S tg[1000];
  cin >> n;
  for (int i = 0; i < n; i++) cin >> tg[i].x >> tg[i].y >> tg[i].t >> tg[i].p;
  sort(tg, tg + n);
  for (int i = 0; i < n; i++) dp[i] = tg[i].p;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < i; j++) {
      if (hypot(tg[i].x - tg[j].x, tg[i].y - tg[j].y) <= tg[i].t - tg[j].t)
        dp[i] = max(dp[i], dp[j] + tg[i].p);
    }
  double ans = 0;
  for (int i = 0; i < n; i++) ans = max(ans, dp[i]);
  printf("%.9f\n", ans);
}
int main() {
  run();
  return 0;
}
