def num_root(d); m = d % 9; m == 0 ? 9 : m; end N = gets.to_i P = gets.split.map(&:to_i) puts num_root(P.inject(1){|s,v| s * num_root(v) })