#include <bits/stdc++.h>
using namespace std;
const int LMT = 1002;
struct target {
  double x, y, t, p;
  bool operator<(const target &x) const { return t < x.t; }
} tar[LMT];
double dp[LMT];
double dis(target a, target b) {
  return sqrt((a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y));
}
int main() {
  int n;
  double ans = 0;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++)
    scanf("%lf%lf%lf%lf", &tar[i].x, &tar[i].y, &tar[i].t, &tar[i].p);
  sort(&tar[1], &tar[1] + n);
  tar[0] = tar[1];
  for (int i = 1; i <= n; i++) {
    dp[i] = tar[i].p;
    for (int j = 1; j < i; j++)
      if (dis(tar[i], tar[j]) + tar[j].t <= tar[i].t)
        dp[i] = max(dp[i], dp[j] + tar[i].p);
    ans = max(ans, dp[i]);
  }
  printf("%.8lf\n", ans);
  return 0;
}
