#include <bits/stdc++.h>
int main() {
  int n;
  scanf("%d", &n);
  int x[n], y[n], t[n];
  double p[n];
  for (int i = 0; i < n; ++i) scanf("%d%d%d%lf", x + i, y + i, t + i, p + i);
  for (int i = 0; i < n; ++i)
    for (int j = i + 1; j < n; ++j)
      if (t[j] < t[i])
        std::swap(x[i], x[j]), std::swap(y[i], y[j]), std::swap(t[i], t[j]),
            std::swap(p[i], p[j]);
  double best[n];
  for (int i = n - 1; i >= 0; --i) {
    best[i] = p[i];
    for (int j = i + 1; j < n; ++j)
      if (t[j] - t[i] >= hypot(x[i] - x[j], y[i] - y[j]))
        best[i] = std::max(best[i], p[i] + best[j]);
  }
  for (int i = 1; i < n; ++i)
    if (best[i] > best[0]) best[0] = best[i];
  printf("%.9lf\n", best[0]);
}
