#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using pii = pair<int, int>;

struct P {
  int s, w;
  P() {}
  P(int s, int w) : s(s), w(w) {}
  bool operator <= (const P& a) {
    return s <= a.s && w <= a.w;
  }
};

const vector<P> v = {{60, 2}, {80, 5}, {100, 10}, {120, 15}, {140, 20}, {160, 25}};

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  int n;
  while (cin >> n, n) {
    int ans = 0;
    for (int i = 0; i < n; i++) {
      int x, y, h, w;
      cin >> x >> y >> h >> w;
      P p(x + y + h, w);
      for (int j = 0; j < 6; j++) {
        if (p <= v[j]) {
          ans += v[j].s * 10;
          break;
        }
      }
    }
    cout << ans << endl;
  }

  return 0;
}
