#include <bits/stdc++.h>
using namespace std;
pair<long double, long double> MV(pair<long double, long double> a,
                                  pair<long double, long double> b) {
  return make_pair(b.first - a.first, b.second - a.second);
}
long double area(pair<long double, long double> a,
                 pair<long double, long double> b,
                 pair<long double, long double> c) {
  return MV(a, b).first * MV(a, c).second - MV(a, b).second * MV(a, c).first;
}
long double SP(pair<long double, long double> a,
               pair<long double, long double> b) {
  return a.first * b.first + a.second * b.second;
}
long double VP(pair<long double, long double> a,
               pair<long double, long double> b,
               pair<long double, long double> c) {
  return MV(a, b).first * MV(a, c).second - MV(a, b).second * MV(a, c).first;
}
long double len(pair<long double, long double> a,
                pair<long double, long double> b) {
  return sqrt(MV(a, b).first * MV(a, b).first +
              MV(a, b).second * MV(a, b).second);
}
long double distptsect(pair<long double, long double> a,
                       pair<long double, long double> b,
                       pair<long double, long double> c) {
  if (SP(MV(b, a), MV(b, c)) < 0 || SP(MV(c, a), MV(c, b)) < 0) return 1e12;
  return abs(area(a, b, c) / len(b, c));
}
bool intersect_1(long double a, long double b, long double c, long double d) {
  if (a > b) swap(a, b);
  if (c > d) swap(c, d);
  return max(a, c) <= min(b, d);
}
bool intersect(pair<long double, long double> a,
               pair<long double, long double> b,
               pair<long double, long double> c,
               pair<long double, long double> d) {
  return intersect_1(a.first, b.first, c.first, d.first) &&
         intersect_1(a.second, b.second, c.second, d.second) &&
         area(a, b, c) * area(a, b, d) <= 0 &&
         area(c, d, a) * area(c, d, b) <= 0;
}
vector<pair<int, pair<pair<long double, long double>, long double>>> g;
long double d[1001];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  long long temp;
  g.resize(n);
  for (int i = 0; i < (int)(n); ++i)
    cin >> g[i].second.first.first >> g[i].second.first.second >> g[i].first >>
        g[i].second.second;
  sort(g.begin(), g.end());
  for (int i = 0; i < (int)(n); ++i) {
    d[i] = g[i].second.second;
    for (int j = 0; j < (int)(i); ++j) {
      if (len(g[i].second.first, g[j].second.first) <= g[i].first - g[j].first)
        d[i] = max(d[i], d[j] + g[i].second.second);
    }
  }
  long double max = 0;
  for (int i = 0; i < (int)(n); ++i) {
    if (d[i] > max) max = d[i];
  }
  cout.precision(15);
  cout << fixed << max;
  return 0;
}
