#include <bits/stdc++.h>
using namespace std;
bool poss(long long int x, long long int y, long long int x1, long long int y1,
          long long int t) {
  long long int d = (x - x1) * (x - x1) + (y - y1) * (y - y1);
  if (d <= t * t) return true;
  return false;
}
int main() {
  long long int n, x, y, t;
  double p;
  map<pair<long long int, long long int>, double> m;
  vector<pair<long long int, pair<long long int, long long int> > > v;
  cin >> n;
  for (long long int i = 0; i < n; i++) {
    cin >> x >> y >> t >> p;
    m[make_pair(x, y)] = p;
    v.push_back(make_pair(t, make_pair(x, y)));
  }
  sort(v.begin(), v.end());
  double ans[n + 1], max_ans = 0;
  for (long long int i = 0; i < n; i++) ans[i] = m[v[i].second];
  for (long long int i = 0; i < n; i++) {
    for (long long int j = i - 1; j >= 0; j--) {
      if (!poss(v[j].second.first, v[j].second.second, v[i].second.first,
                v[i].second.second, v[j].first - v[i].first))
        continue;
      ans[i] = max(ans[i], ans[j] + m[v[i].second]);
    }
  }
  for (long long int i = 0; i < n; i++) max_ans = max(ans[i], max_ans);
  cout << fixed << setprecision(10) << max_ans << endl;
}
