#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
struct item {
  int x, y, t;
  long double p;
};
bool operator<(const item& a, const item& b) { return a.t < b.t; }
const int MAXN = 1e3 + 3;
item a[MAXN];
long double dp[MAXN];
int n;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i].x >> a[i].y >> a[i].t >> a[i].p;
  }
  sort(a, a + n);
  for (int i = 0; i < n; i++) {
    dp[i] = a[i].p;
    for (int j = 0; j < i; j++) {
      if ((a[i].t - a[j].t) * 1ll * (a[i].t - a[j].t) >=
          (a[i].x - a[j].x) * 1ll * (a[i].x - a[j].x) +
              (a[i].y - a[j].y) * 1ll * (a[i].y - a[j].y)) {
        dp[i] = max(dp[i], dp[j] + a[i].p);
      }
    }
  }
  long double ans = 0;
  for (int i = 0; i < n; i++) ans = max(ans, dp[i]);
  cout.precision(12);
  cout << fixed << ans;
  return 0;
}
