io.stdin:read("*l") print((function (f, s) return f(s) end)(function (s) local t,n,r = {},0,0 for e in s:gmatch("%d+") do e=tonumber(e) n=n+e table.insert(t,e) end n = n/10 for _,v in ipairs(t) do if v <= n then r = r+1 end end return r*30 end, io.stdin:read("*l")))