#include <bits/stdc++.h>
using namespace std;
struct Target {
  int x, y, t;
  double p;
};
inline double dist(const Target &a, const Target &b) {
  return hypot(a.x - b.x, a.y - b.y);
}
int main() {
  if (fopen("input.txt", "r")) {
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
  }
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n;
  cin >> n;
  vector<Target> a;
  for (int i = 0; i != n; ++i) {
    int x, y, t;
    double p;
    cin >> x >> y >> t >> p;
    a.push_back({x, y, t, p});
  }
  sort(a.begin(), a.end(), [](Target &a, Target &b) { return a.t < b.t; });
  vector<double> dp(n);
  for (int i = 0; i != n; ++i) {
    dp[i] = a[i].p;
    for (int j = 0; j != i; ++j)
      if (dist(a[i], a[j]) <= a[i].t - a[j].t)
        dp[i] = max(dp[i], dp[j] + a[i].p);
  }
  auto ans = *max_element(dp.begin(), dp.end());
  cout << fixed;
  cout.precision(8);
  cout << ans;
  return 0;
}
