x = 1 n = gets.to_i a = gets.chomp.split(" ") for i in 0..n-1 x *= a[i].to_i while x>=10 and x%10==0 x/=10 end end y = 0 while x>0 y+=x%10 if y>=10 y = y/10 + y%10 end x/=10 end print y