#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1005;
long long n, x[MAXN], y[MAXN], t[MAXN], idx[MAXN];
double p[MAXN], dp[MAXN], sol;
bool idxCMP(int i, int j) { return t[i] < t[j]; }
int dist2(int i, int j) {
  return (x[i] - x[j]) * (x[i] - x[j]) + (y[i] - y[j]) * (y[i] - y[j]);
}
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> x[i] >> y[i] >> t[i] >> p[i];
    idx[i] = i;
  }
  sort(idx, idx + n, idxCMP);
  for (int i = n - 1; i >= 0; i--) {
    for (int j = i + 1; j < n; j++)
      if ((t[idx[j]] - t[idx[i]]) * (t[idx[j]] - t[idx[i]]) >=
          dist2(idx[i], idx[j]))
        dp[i] = max(dp[i], dp[j]);
    dp[i] += p[idx[i]];
    sol = max(sol, dp[i]);
  }
  cout << setprecision(7) << fixed;
  cout << sol << endl;
}
