#include <bits/stdc++.h>
using namespace std;
const int N = 50005;
const unsigned long long MOD = 1e8 + 7;
const unsigned long long MAX = 1e15;
int X[N], Y[N], T[N], K[N];
int n;
double P[N], dp[N], ans = 0;
bool cmp(int a, int b) { return T[a] < T[b]; }
double dist(int i, int j) {
  double ans = sqrt((X[K[i]] - X[K[j]]) * (X[K[i]] - X[K[j]]) +
                    (Y[K[i]] - Y[K[j]]) * (Y[K[i]] - Y[K[j]]));
  return ans;
}
void work() {
  for (int i = 1; i <= n; i++) {
    dp[i] = P[K[i]];
    for (int j = 1; j < i; j++)
      if (dist(i, j) + T[K[j]] <= T[K[i]]) dp[i] = max(dp[j] + P[K[i]], dp[i]);
    ans = max(ans, dp[i]);
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d%d%d%lf", &X[i], &Y[i], &T[i], &P[i]);
    K[i] = i;
  }
  sort(K + 1, K + n + 1, cmp);
  work();
  printf("%.7f\n", ans);
}
