#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define SORT(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define EQ(a,b) (abs((a)-(b))<eps)
vector<int> sz,w,v;
int main()
{
	for(int i=60;i<=160;i+=20){sz.pb(i);v.pb(i*10);}
	w.pb(2);
	for(int i=1;i<=5;i++)w.pb(i*5);
	while(1)
	{
		int n;
		int ans = 0;
		scanf("%d",&n);
		if(n==0)break;
		for(int i=0;i<n;i++)
		{
			int x,y,h,we;
			scanf("%d %d %d %d",&x,&y,&h,&we);
			int s = x+y+h;
			for(int j=0;j<6;j++)
			{
				if(s<=sz[j]&&we<=w[j])
				{
					ans+=v[j];
					break;
				}
			}
		}
		printf("%d\n",ans);
	}
	return 0;
}