#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
const int N = 400004;
int X[N], Y[N], S[N], T[N];
double P[N], D[N];
bool cmp(int a, int b) { return T[a] < T[b]; }
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> X[i] >> Y[i] >> T[i] >> P[i];
    S[i] = i;
  }
  sort(S, S + n, cmp);
  double ans = 0;
  for (int i = 0; i < n; ++i) {
    int u = S[i];
    D[u] = P[u];
    for (int j = 0; j < i; ++j) {
      int v = S[j];
      if ((X[u] - X[v]) * (X[u] - X[v]) + (Y[u] - Y[v]) * (Y[u] - Y[v]) <=
          1LL * (T[u] - T[v]) * (T[u] - T[v]))
        D[u] = max(D[u], P[u] + D[v]);
    }
    ans = max(ans, D[u]);
  }
  cout << setprecision(14) << ans;
}
