#include <bits/stdc++.h>
using namespace std;
const double PI = 3.14159265358979323846264338327;
long long n, A;
struct triple {
  long long first;
  long long second;
  long long ind;
};
bool comp1(triple x, triple y) { return x.first < y.first; }
bool comp2(triple x, triple y) {
  if (x.first + x.second != y.first + y.second)
    return A - (x.first + x.second) < A - (y.first + y.second);
  else
    return x.second > y.second;
}
struct mishen {
  int x;
  int y;
  int t;
  double ver;
  mishen(int x, int y, int t, double ver) {
    this->x = x;
    this->y = y;
    this->t = t;
    this->ver = ver;
  }
};
bool comp(mishen m1, mishen m2) { return m1.t < m2.t; }
double rast(int x, int y, int x1, int y1) {
  return sqrt((x - x1) * (x - x1) + (y - y1) * (y - y1));
}
int main() {
  cout.precision(9);
  cout << fixed;
  int n;
  cin >> n;
  vector<mishen> arr;
  for (int i = 0; i < n; i++) {
    int x, y, t;
    cin >> x >> y >> t;
    double p;
    cin >> p;
    arr.push_back(mishen(x, y, t, p));
  }
  sort(arr.begin(), arr.end(), comp);
  vector<double> dp(n, 0);
  vector<vector<bool> > u(n, vector<bool>(n, false));
  for (int i = 0; i < n; i++) {
    mishen m = arr[i];
    for (int j = i - 1; j >= 0; j--) {
      mishen m1 = arr[j];
      if (rast(m.x, m.y, m1.x, m1.y) > (m.t - m1.t)) continue;
      u[i][j] = true;
      u[j][i] = true;
    }
  }
  for (int i = 0; i < n; i++) {
    dp[i] = arr[i].ver;
    double max = 0;
    for (int j = i - 1; j >= 0; j--) {
      if (u[i][j] && max < dp[j]) max = dp[j];
    }
    dp[i] += max;
  }
  cout << *max_element(dp.begin(), dp.end());
  return 0;
}
