#include <stdio.h>
#include <stdlib.h>
int main()
{
double s=0, d=0,b=0,a=0,c=0;
for(int i=0;i<5;i++)
{
scanf("%lf %lf",&s,&d);
a=d-s;
c=c+a;
if(1<=a&&a<4)
{
b=b+(a-1)*10000;
}
else if(a>=5)
{
b=b+40000;
}
else if(a==4.5)
{
b=b+35000;
}
else if(a>=4)
{
b=b+30000;
}
else
{
b=b;
}
a=0;
}
if(c<=5)
{
b=b*21/20;
printf("%0.0lf",b);
}
else if(c>=15)
{
b=b*19/20;
printf("%0.0lf",b);
}
else
{
printf("%0.0lf",b);
}
return 0;
}