#include <bits/stdc++.h>
using namespace std;
const int maxn = 1005;
int x[maxn], y[maxn], t[maxn], ord[maxn];
double p[maxn], dp[maxn];
bool cmp(int i, int j) { return t[i] < t[j]; }
inline long long dist(long long x, long long y) { return (x * x + y * y); }
inline long long square(long long x) { return x * x; }
int main() {
  ios_base::sync_with_stdio(0);
  cin.clear();
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> x[i] >> y[i] >> t[i] >> p[i];
    ord[i] = i;
  }
  sort(ord, ord + n, cmp);
  for (int i = 0; i < n; i++) {
    dp[i] = p[ord[i]];
    for (int j = 0; j < i; j++) {
      if (square(t[ord[i]] - t[ord[j]]) >=
          dist(x[ord[i]] - x[ord[j]], y[ord[i]] - y[ord[j]]))
        dp[i] = max(dp[i], p[ord[i]] + dp[j]);
    }
  }
  double ans = 0;
  for (int i = 0; i < n; i++) ans = max(ans, dp[i]);
  cout << setprecision(7) << fixed << ans;
}
