#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
const double eps = 1e-8;
const int nm = 1005;
int n, k, m, t;
struct Node {
  int x, y, t;
  double p;
};
Node a[nm];
long long res;
char s[nm];
bool check[nm];
long long Pow(int x, int mu) {
  if (mu == 0) return 1ll;
  long long res = Pow(x, mu >> 1);
  res = res * res % MOD;
  if (mu & 1) res = res * x % MOD;
  return res;
}
bool cmp(Node u, Node v) { return u.t < v.t; }
double dp[nm];
int main() {
  int i, j, x, y, z, w;
  scanf("%d", &n);
  for (i = 1; i <= n; i++) {
    scanf("%d%d%d", &a[i].x, &a[i].y, &a[i].t);
    scanf("%lf", &a[i].p);
  }
  sort(a + 1, a + n + 1, cmp);
  for (i = 1; i <= n; i++) dp[i] = a[i].p;
  for (i = 1; i <= n; i++)
    for (j = i - 1; j >= 1; j--) {
      if (hypot(a[i].x - a[j].x, a[i].y - a[j].y) - eps <
              (double)a[i].t - a[j].t &&
          dp[j] + a[i].p > dp[i])
        dp[i] = dp[j] + a[i].p;
    }
  double Max = 0;
  for (i = 1; i <= n; i++)
    if (dp[i] > Max) Max = dp[i];
  printf("%.12lf ", Max);
  ;
  return 0;
}
