#include <bits/stdc++.h>
using namespace std;
vector<int> f(3);
vector<int> b(3);
double dist(pair<int, int> a, pair<int, int> b) {
  return sqrt(double((a.first - b.first) * (a.first - b.first) +
                     (a.second - b.second) * (a.second - b.second)));
}
double eps = 0.000000001;
int main() {
  int n;
  scanf("%d", &n);
  vector<pair<pair<int, double>, pair<int, int> > > v(n);
  for (int i = 0; i < n; ++i) {
    scanf("%d%d%d%lf", &(v[i].second.first), &(v[i].second.second),
          &(v[i].first.first), &(v[i].first.second));
  }
  sort(v.begin(), v.end());
  vector<double> best(n);
  double maxp = 0;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < i; ++j) {
      if (dist(v[i].second, v[j].second) - eps <
          v[i].first.first - v[j].first.first) {
        best[i] = max(best[i], best[j] + v[i].first.second);
      }
    }
    best[i] = max(best[i], v[i].first.second);
    maxp = max(maxp, best[i]);
  }
  printf("%.10lf\n", maxp);
}
