#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1.0);
const double eps = 1e-8;
struct xx {
  int x, y;
  long long t;
  double p;
  bool operator<(const xx &a) const { return t < a.t; }
  void get() { cin >> x >> y >> t >> p; }
};
xx pt[1010];
double f[1010];
int n;
long long dis(xx a, xx b) {
  return (long long)(a.x - b.x) * (a.x - b.x) +
         (long long)(a.y - b.y) * (a.y - b.y);
}
int main() {
  cin >> n;
  for (int i = 1; i <= n; ++i) pt[i].get();
  sort(pt + 1, pt + n + 1);
  for (int i = 1; i <= n; ++i) f[i] = pt[i].p;
  for (int i = 1; i <= n; ++i)
    for (int j = i + 1; j <= n; ++j)
      if (f[i] + pt[j].p > f[j] &&
          dis(pt[i], pt[j]) <= (pt[j].t - pt[i].t) * (pt[j].t - pt[i].t))
        f[j] = f[i] + pt[j].p;
  double res = 0;
  for (int i = 1; i <= n; ++i) res = max(res, f[i]);
  printf("%.10f\n", res);
  return 0;
}
