N = gets.to_i P = gets.split(" ").map{|s| s.to_i} k = 1 P.each {|x| k *= x % 9 == 0 ? 9 : x % 9 } puts k % 9