n = $stdin.gets.to_i ans = 1 inp = 0 n.times do inp = $stdin.gets.to_i ans = ans * inp end puts ans % 9