#include <bits/stdc++.h>
using namespace std;
struct target {
  target(double a, double b, double c, double d) : x(a), y(b), t(c), p(d) {
    mm = 0;
    kol = 0;
  };
  double x, y, t, p, mm;
  int kol;
};
bool operator<(const target& a, const target& b) { return a.t < b.t; }
double dist(const target& a, const target& b) {
  return sqrt((a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y));
}
int main() {
  int n;
  scanf("%d", &n);
  double a, b, c, d, mx = 0, r = 0;
  vector<target> v;
  for (int i = 0; i < n; i++) {
    cin >> a >> b >> c >> d;
    v.push_back(target(a, b, c, d));
  }
  sort(v.begin(), v.end());
  bool end[1002] = {0};
  for (int i = 0; i < n; i++) {
    v[i].mm += v[i].p;
    for (int j = i + 1; j < n; j++) {
      if (dist(v[i], v[j]) <= v[j].t - v[i].t) {
        end[i] = true;
        if (v[j].mm < v[i].mm) v[j].mm = v[i].mm;
        v[j].kol++;
      }
    }
    if (mx < v[i].mm) mx = v[i].mm;
  }
  cout.precision(15);
  cout << mx << endl;
  return 0;
}
