while (ls = gets.split.map{|i|i.to_i})!=[0]
  ls.map!{|i|i=[i,10].min}
  ans=ls.inject(:+)
  if ans>21
    ans=0
  else
    c=ls.count(1)
    for i in 1..c
      ans+=10 if ans+10 <= 21
    end
  end
  puts ans
end