#include <bits/stdc++.h>
using namespace std;
long long int powmod(long long int a, int b, int n) {
  long long int rm = 1;
  while (b) {
    if (b % 2) {
      rm = (rm * a) % n;
    }
    a = (a * a) % n;
    b /= 2;
  }
  return rm;
}
double Expcteddp[1010] = {0}, p[1010];
vector<pair<long long int, int> > V;
long long int x[1010], y[1010];
long long int Sqdis(int i, int j) {
  return (x[V[i].second] - x[V[j].second]) * (x[V[i].second] - x[V[j].second]) +
         (y[V[i].second] - y[V[j].second]) * (y[V[i].second] - y[V[j].second]);
}
int main() {
  int n, tq;
  cin >> n;
  double ans = 0.0;
  V.push_back(make_pair(0, 0));
  p[0] = x[0] = y[0] = 0;
  for (int i = int(1); i <= (int)n; i++) {
    cin >> x[i] >> y[i] >> tq >> p[i];
    V.push_back(make_pair(tq, i));
  }
  sort(V.begin() + 1, V.end());
  for (int i = 1; i <= n; ++i) {
    Expcteddp[i] = max(Expcteddp[i], p[V[i].second]);
    for (int j = i + 1; j <= n; ++j) {
      if (Sqdis(i, j) <=
          (V[i].first - V[j].first) * (V[i].first - V[j].first)) {
        Expcteddp[j] = max(Expcteddp[j], Expcteddp[i] + p[V[j].second]);
      }
    }
    ans = max(ans, Expcteddp[i]);
  }
  printf("%.10lf\n", ans);
  return 0;
}
