#include <bits/stdc++.h>
using namespace std;
int n;
struct pt {
  double x, y, t, p;
};
vector<pt> v;
bool func(pt &a, pt &b) { return a.t < b.t; }
double res[2000];
double dist(pt &a, pt &b) {
  return sqrt((a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y));
}
int main() {
  cin >> n;
  pt tmp;
  for (int i = 0; i < n; i++) {
    cin >> tmp.x >> tmp.y >> tmp.t >> tmp.p;
    v.push_back(tmp);
  }
  sort(v.begin(), v.end(), func);
  for (int i = 0; i < v.size(); i++) {
    res[i] = v[i].p;
  }
  for (int i = 0; i < v.size(); i++) {
    for (int j = i + 1; j < v.size(); j++) {
      if (dist(v[i], v[j]) <= v[j].t - v[i].t) {
        res[j] = max(res[j], res[i] + v[j].p);
      }
    }
  }
  int m = 0;
  for (int i = 0; i < v.size(); i++) {
    if (res[i] > res[m]) {
      m = i;
    }
  }
  cout.precision(10);
  cout << res[m];
}
