#include <bits/stdc++.h>
using namespace std;
struct target {
  int x;
  int y;
  int t;
  int p;
  target(int x, int y, int t, int p) : x(x), y(y), t(t), p(p){};
};
bool comp(target t1, target t2) { return t1.t < t2.t; }
int n;
vector<target> tar;
int mem[1005];
int dp(int lst) {
  if (lst == n + 1) return 0;
  if (mem[lst] != -1) return mem[lst];
  int ret = 0;
  for (int i = lst + 1; i <= n; i++) {
    int d = (tar[i].x - tar[lst].x) * (tar[i].x - tar[lst].x) +
            (tar[i].y - tar[lst].y) * (tar[i].y - tar[lst].y);
    int t = tar[i].t - tar[lst].t;
    if (lst == 0 || 1LL * t * t >= d) ret = max(ret, tar[i].p + dp(i));
  }
  return mem[lst] = ret;
}
int main() {
  int x, y, t;
  double p;
  cin >> n;
  tar = vector<target>(n + 1, target(0, 0, 0, 0));
  for (int i = 1; i <= n; i++) {
    cin >> x >> y >> t >> p;
    tar[i] = target(x, y, t, (int)round(p * 1000000));
  }
  sort(tar.begin() + 1, tar.end(), comp);
  memset(mem, -1, sizeof(mem));
  cout << setprecision(12) << dp(0) / 1000000.0;
  return 0;
}
