#include<stdio.h>
int main()
{
int n, i, j, a[5000][4]= {}, b[11000], c[11000], max = 0, mmax = 0;
scanf("%d", &n);
for(i=0; i<n; i++)
{
for(j=0; j<4; j++)
{
scanf("%d", &a[i][j]);
}
}
for(i=0; i<n; i++)
{
int c[1000]={};
for(j=0; j<4; j++)
{
if(a[i][j]==1)
c[0]++;
else if(a[i][j]==2)
c[1]++;
else if(a[i][j]==3)
c[2] += 1;
else if(a[i][j]==4)
c[3] += 1;
else if(a[i][j]==5)
c[4] += 1;
else if(a[i][j]==6)
c[5] += 1;
}
for(j=0; j<6; j++)
{
if(c[j]>max)
{
max = c[j];
mmax = j+1;
}
//////////////////////////////////////////
else if(c[j]==max&&max==2&&c[j]==2)
{
b[i] = 2000+mmax*500+(j)*500;
max = 0;
}
////////////////////////////////////////////
}
if(max==1)
{
for(j=0; j<4; j++)
{
if(a[i][j]>max)
max = a[i][j];
}
b[i] = max*100;
}
else if(max==2)
b[i] = 1000+mmax*100;
else if(max==3)
b[i] = 10000+mmax*1000;
else if(max==4)
b[i] = 50000+mmax*5000;
max = 0;
mmax = 0;
//printf("%d\n", b[i]);
}
for(i = 0; i < n; i++)
{
if(b[i]>max)
{
max = b[i];
}
}
printf("%d", max);
return 0;
}