n,i,a[99];main(s){for(;~scanf("%d",a+i);s+=a[i++]*!!i);for(;--i;a[i]*10>s||n++);n=!printf("%d",n*30);}