#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
long long mypow(long long x, int st) {
  long long ans = {1};
  while (st) {
    if (st & 1) ans = (ans * x) % mod;
    x = (x * x) % mod;
    st /= 2;
  }
  return ans % mod;
}
struct abc {
  double x, y, p;
  int t;
  abc() {}
  abc(double x, double y, int t, double p) : x(x), y(y), t(t), p(p) {}
};
bool cmp(abc a, abc b) { return a.t < b.t; }
bool f(abc a, abc b) {
  double tp = abs(a.t - b.t);
  double x = a.x - b.x;
  double y = a.y - b.y;
  return tp >= sqrt(x * x + y * y);
}
double dp[100100];
int main() {
  int n;
  cin >> n;
  vector<abc> v(n);
  for (abc& i : v) scanf("%lf %lf %d %lf", &i.x, &i.y, &i.t, &i.p);
  sort(v.begin(), v.end(), cmp);
  double ans = 0.0;
  for (int i = 0; i < n; i++) {
    dp[i] = v[i].p;
    double ma = 0.0;
    for (int j = 0; j < i; j++) {
      if (ma < dp[j] && f(v[i], v[j])) ma = dp[j];
    }
    dp[i] += ma;
    ans = max(ans, dp[i]);
  }
  printf("%.9f", ans);
}
