#include <bits/stdc++.h>
using namespace std;
int adj[4][2] = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}};
int coradj[4][2] = {{1, 1}, {-1, 1}, {-1, -1}, {1, -1}};
int alladj[8][2] = {{1, 1},   {0, 1},  {-1, 1}, {-1, 0},
                    {-1, -1}, {0, -1}, {1, -1}, {1, 0}};
int gcd(int a, int b) { return ((b) ? gcd(b, a % b) : a); }
int rem(int a, int n) { return (a % n + n) % n; }
struct target {
  int x, y, t;
  double p;
};
bool operator<(target a, target b) { return a.t < b.t; }
int n;
target a[(1000 + 100)];
double d[(1000 + 100)];
bool arrive(int x, int y) {
  double dt = (sqrt(((((a[x].x) - (a[y].x)) * ((a[x].x) - (a[y].x)))) +
                    ((((a[x].y) - (a[y].y)) * ((a[x].y) - (a[y].y))))));
  return (dt <= a[y].t - a[x].t);
}
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    int x, y, t;
    double p;
    cin >> x >> y >> t >> p;
    a[i].x = x;
    a[i].y = y;
    a[i].t = t;
    a[i].p = p;
  }
  sort(a, a + n);
  d[0] = a[0].p;
  for (int i = 0; i < n; i++) {
    d[i] = a[i].p;
    for (int j = 0; j < i; j++)
      if (arrive(j, i)) d[i] = max(d[i], d[j] + a[i].p);
  }
  double best = 0;
  for (int i = 0; i < n; i++) best = max(best, d[i]);
  for (int i = 0; i < n; i++) cerr << d[i] << ' ';
  cerr << endl;
  cout << fixed << setprecision(6) << best << endl;
  return 0;
}
