#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:16777216")
using namespace std;
const int DIM = 1100;
int n;
pair<pair<int, double>, pair<int, int> > pp[DIM];
int sqr(int q) { return q * q; }
double df[DIM];
int dist(int i, int j) {
  return sqr(pp[i].second.first - pp[j].second.first) +
         sqr(pp[i].second.second - pp[j].second.second);
}
double f(int k) {
  if (df[k] != -1) return df[k];
  double res = pp[k].first.second;
  for (int i = (0); i < (k); i++) {
    int tt = pp[k].first.first - pp[i].first.first;
    if (dist(i, k) <= (long long)tt * tt) {
      res = max(res, pp[k].first.second + f(i));
    }
  }
  return df[k] = res;
}
int main() {
  for (int i = (0); i < (DIM); i++) df[i] = -1.0;
  scanf("%d", &n);
  for (int i = (0); i < (n); i++) {
    scanf("%d%d%d%lf", &pp[i].second.first, &pp[i].second.second,
          &pp[i].first.first, &pp[i].first.second);
  }
  sort(pp, pp + n);
  double ans = 0.0;
  for (int i = (0); i < (n); i++) ans = max(ans, f(i));
  printf("%.8lf\n", ans);
  return 0;
}
