#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>

#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define repi(i,a,b) for(int i = (a); i < (b); i++)

using namespace std;

typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;

const int INF=1<<29;
const double EPS=1e-9;

const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};

int main(){
	int n;
	while(cin>>n,n){
		int sum = 0;
		for(int j = 0;j < n;j++){
			int x,y,h,w;
			cin>>x>>y>>h>>w;
			int v =x+y+h;
			int va = -1;
			int wa =-1;
			for(int i =60;i <=160;i+=20){
				if(v <=i){
					va =i;
					break;
				}
			}
			if(va==-1)continue;
			if(w<=2){
				wa =60;
			}else if(w<=5){
				wa =80;
			}else if(w <=10){
				wa =100;
			}else if(w <=15){
				wa =120;
			}else if(w <=20){
				wa =140;
			}else if(w <=25){
				wa =160;
			}
			if(wa==-1)continue;
			//cout <<wa<<" "<<va<<endl;
			sum +=max(wa,va)*10;
		}
		cout <<sum<<endl;
	}
	return 0;
}