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