#include <bits/stdc++.h>
using namespace std;
const int maxn = 4e5 + 1;
const int mod = 10007;
struct str {
  long long x, y, t;
  double p;
  friend bool operator<(str s1, str s) { return s1.t < s.t; }
};
bool check(str s1, str s2) {
  return (s1.t - s2.t) * (s1.t - s2.t) >=
         ((s1.x - s2.x) * (s1.x - s2.x) + (s1.y - s2.y) * (s1.y - s2.y));
}
str a[maxn];
double dp[maxn];
int main() {
  ios_base::sync_with_stdio(0);
  int n;
  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);
  dp[0] = a[0].p;
  for (int i = 1; i < n; i++) {
    dp[i] = a[i].p;
    for (int j = 0; j < i; j++) {
      if (check(a[i], a[j])) dp[i] = max(dp[i], dp[j] + a[i].p);
    }
  }
  double ans = dp[0];
  for (int i = 0; i < n; i++) ans = max(dp[i], ans);
  cout << fixed << setprecision(10) << ans;
  return 0;
}
