p={} #調理時間
r={} #注文-次の注文までの時間
for i in range(5):
    p[i] = int(input())
    if p[i] % 10 != 0:
        r[i] = p[i] + 10 - p[i] % 10

lastnum = 0
for i in range(1,5):
    if r[lastnum] - p[lastnum] < r[i] - p[i]:
        lastnum = i

print(lastnum)

time = 0
for i in range(5):
    if i != lastnum:
        time += r[i]
    else:
        time += p[i]

print(time)