#include <bits/stdc++.h>
using namespace std;
long double dist(long double x1, long double y1, long double x2,
                 long double y2) {
  int x = x1 - x2, y = y1 - y2;
  return sqrt(x * x + y * y);
}
int main() {
  int n;
  cin >> n;
  vector<pair<pair<long double, long double>, pair<long double, long double>>>
      tar;
  long double dp[n + 5], maxi = (long double)0;
  for (int i = 0; i < (n); i++) {
    long double x, y, t, p;
    cin >> x >> y >> t >> p;
    tar.push_back(make_pair(make_pair(t, p), make_pair(x, y)));
  }
  sort((tar).begin(), (tar).end());
  for (int i = 0; i < (n); i++) {
    dp[i] = (long double)0;
    for (int j = 0; j < (i); j++) {
      if (tar[j].first.first + dist(tar[j].second.first, tar[j].second.second,
                                    tar[i].second.first,
                                    tar[i].second.second) <=
          tar[i].first.first) {
        dp[i] = max(dp[i], dp[j]);
      }
    }
    dp[i] += tar[i].first.second;
    maxi = max(maxi, dp[i]);
  }
  cout << setprecision(15) << maxi;
}
