#include <bits/stdc++.h>
using namespace std;
string tostring(long long x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}
int main() {
  int n;
  cin >> n;
  vector<pair<long, pair<double, pair<int, int> > > > T;
  for (int(i) = 0; (i) < (n); (i)++) {
    int x, y;
    long z;
    double f;
    scanf("%d%d%ld%lf", &x, &y, &z, &f);
    T.push_back(make_pair(z, make_pair(f, make_pair(x, y))));
  }
  sort(T.begin(), T.end());
  double dp[1001];
  for (int(i) = 0; (i) < (n); (i)++) dp[i] = T[i].second.first;
  for (int(i) = 0; (i) < (n); (i)++)
    for (int(j) = 0; (j) < (i); (j)++) {
      long t = T[i].first - T[j].first;
      int x = T[i].second.second.first, y = T[i].second.second.second,
          x1 = T[j].second.second.first, y1 = T[j].second.second.second;
      if (t >= sqrt((((x - x1) > 0) ? (x - x1) : -(x - x1)) *
                        (((x - x1) > 0) ? (x - x1) : -(x - x1)) +
                    (((y - y1) > 0) ? (y - y1) : -(y - y1)) *
                        (((y - y1) > 0) ? (y - y1) : -(y - y1))))
        if (dp[j] + T[i].second.first - dp[i] > 0)
          dp[i] = dp[j] + T[i].second.first;
    }
  double ans = 0.0;
  for (int(i) = 0; (i) < (n); (i)++)
    if (ans < dp[i]) ans = dp[i];
  printf("%.6lf\n", ans);
  return 0;
}
