#include <bits/stdc++.h>
using namespace std;
struct node {
  double x, y, t, zhi;
  bool operator<(const node& other) const { return t < other.t; }
};
vector<node> vn;
double dp[1005];
double suan(int a, int b) {
  return sqrt((vn[a].x - vn[b].x) * (vn[a].x - vn[b].x) +
              (vn[a].y - vn[b].y) * (vn[a].y - vn[b].y));
}
int main() {
  int n;
  memset(dp, 0, sizeof(dp));
  cin >> n;
  double ans = 0;
  for (int i = 1; i <= n; i++) {
    node g;
    cin >> g.x >> g.y >> g.t >> g.zhi;
    vn.push_back(g);
  }
  sort(vn.begin(), vn.end());
  for (int i = 0; i < vn.size(); i++) {
    dp[i] = vn[i].zhi;
    for (int j = 0; j < i; j++) {
      if (vn[i].t - vn[j].t >= suan(i, j))
        dp[i] = max(dp[i], dp[j] + vn[i].zhi);
    }
    ans = max(ans, dp[i]);
  }
  printf("%.6lf\n", ans);
  return 0;
}
