#include <bits/stdc++.h>
using namespace std;
struct Node {
  long long x, y, t;
  double p;
  bool operator<(const Node &a) const { return t < a.t; };
};
int main() {
  int n;
  scanf("%d", &n);
  vector<Node> v;
  for (int i = 0; i < n; ++i) {
    Node node;
    scanf("%lld %lld %lld %lf", &node.x, &node.y, &node.t, &node.p);
    v.push_back(node);
  }
  sort(v.begin(), v.end());
  vector<vector<double>> dis(n, vector<double>(n));
  for (int i = 0; i < n; ++i)
    for (int j = i + 1; j < n; ++j)
      dis[i][j] = dis[j][i] = (v[i].x - v[j].x) * (v[i].x - v[j].x) +
                              (v[i].y - v[j].y) * (v[i].y - v[j].y);
  vector<double> dp(n);
  for (int i = 0; i < n; ++i) {
    dp[i] = v[i].p;
    for (int j = 0; j < i; ++j) {
      if (dis[i][j] > (v[i].t - v[j].t) * (v[i].t - v[j].t)) continue;
      dp[i] = max(dp[i], dp[j] + v[i].p);
    }
  }
  double ans = 0;
  for (int i = 0; i < n; ++i) ans = max(ans, dp[i]);
  printf("%.10lf\n", ans);
  return 0;
}
