#include <bits/stdc++.h>
using namespace std;
struct cel {
  long long x, y, t;
  double p;
};
long long pot(long long x) { return x * x; }
bool porownanie(cel a, cel b) {
  if (a.t < b.t) return true;
  return false;
}
int main() {
  ios_base::sync_with_stdio(0);
  int n;
  cin >> n;
  vector<cel> a(n);
  for (int i = 0; i < n; ++i) cin >> a[i].x >> a[i].y >> a[i].t >> a[i].p;
  sort(a.begin(), a.end(), porownanie);
  vector<double> dp(n);
  for (int i = 0; i < n; ++i) {
    dp[i] = a[i].p;
    for (int j = 0; j < i; ++j)
      if (pot(a[i].x - a[j].x) + pot(a[i].y - a[j].y) <= pot(a[i].t - a[j].t))
        dp[i] = max(dp[i], dp[j] + a[i].p);
  }
  double odp = 0.0;
  for (int i = 0; i < n; ++i) odp = max(odp, dp[i]);
  cout << setprecision(15) << fixed;
  cout << odp;
  return 0;
}
