#include <bits/stdc++.h>
using namespace std;
template <class T>
struct rge {
  T b, e;
};
template <class T>
rge<T> range(T i, T j) {
  return rge<T>{i, j};
};
template <class A, class B>
ostream &operator<<(ostream &os, pair<A, B> p) {
  return os << "(" << p.first << ", " << p.second << ")";
}
template <class T>
ostream &operator<<(ostream &os, rge<T> d) {
  os << "[";
  for (auto it = d.b; it != d.e; it++) os << (it == d.b ? "" : ", ") << *it;
  return os << "]";
}
const int N = 1005;
struct target {
  int x, y, t;
  double p;
  friend istream &operator>>(istream &is, target &ta) {
    is >> ta.x >> ta.y >> ta.t >> ta.p;
    return is;
  }
};
target targ[N];
double dp[N];
int n;
double squ(double x) { return x * x; }
bool shot(target &a, target &b) {
  return squ(a.x - b.x) + squ(a.y - b.y) <= squ(a.t - b.t);
}
template <class T>
void umax(T &a, T b) {
  a = max(a, b);
}
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0), cout.precision(15);
  cin >> n;
  for (int i = (0); i <= ((n)-1); i += (+1)) {
    cin >> targ[i];
  }
  sort(targ, targ + n, [&](target a, target b) { return a.t < b.t; });
  for (int i = (0); i <= ((n)-1); i += (+1)) {
    dp[i] = targ[i].p;
    for (int j = (0); j <= ((i)-1); j += (+1)) {
      if (shot(targ[i], targ[j])) {
        umax(dp[i], dp[j] + targ[i].p);
      }
    }
  }
  double ans = *max_element(dp, dp + n);
  cout << fixed << ans << '\n';
  return 0;
}
