#include <bits/stdc++.h>
using namespace std;
const int INF = 2147483647;
const long long LLINF = 9223372036854775807LL;
const int maxn = 1010;
int x[maxn], y[maxn], t[maxn];
double p[maxn];
double dp[maxn];
int order[maxn];
bool cmp(int i1, int i2) { return t[i1] < t[i2]; }
const double eps = 1e-9;
vector<int> a[maxn];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; ++i)
    scanf("%d%d%d%lf", &x[i], &y[i], &t[i], &p[i]), order[i] = i;
  sort(order, order + n, cmp);
  for (int i = 0; i < n; ++i) {
    int i1 = order[i];
    for (int j = i + 1; j < n; ++j) {
      int i2 = order[j];
      double len = sqrt((x[i1] - x[i2]) * (x[i1] - x[i2]) +
                        (y[i1] - y[i2]) * (y[i1] - y[i2]) + .0);
      if (t[i2] - t[i1] >= len - eps) {
        a[i1].push_back(i2);
      }
    }
  }
  double best = 0;
  for (int i = n - 1; i >= 0; --i) {
    int cur = order[i];
    dp[cur] = 0;
    for (int j = 0; j < int((a[cur]).size()); ++j)
      dp[cur] = max(dp[cur], dp[a[cur][j]]);
    dp[cur] += p[cur];
    best = max(best, dp[cur]);
  }
  printf("%.15lf\n", best);
  return 0;
}
