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