#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int n, i, j;
  cin >> n;
  long double dp[n], ans = 0;
  vector<vector<long double> > a(n);
  for (i = 0; i < n; i++) {
    double v[4];
    cin >> v[1] >> v[2] >> v[0] >> v[3];
    a[i].push_back(v[0]);
    a[i].push_back(v[1]);
    a[i].push_back(v[2]);
    a[i].push_back(v[3]);
  }
  sort(a.begin(), a.end());
  for (i = 0; i < n; i++) {
    dp[i] = a[i][3];
    for (j = 0; j < i; j++) {
      if (hypot(a[i][1] - a[j][1], a[i][2] - a[j][2]) <= a[i][0] - a[j][0]) {
        dp[i] = max(dp[i], dp[j] + a[i][3]);
      }
    }
    ans = max(ans, dp[i]);
  }
  printf("%0.8Lf\n", ans);
}
