using System; using System.Linq; using System.Collections.Generic; using System.IO; class MyClass { public static long DigitSum(long n) { if (n < 10) { return n; } else { return n.ToString().ToCharArray().Select(y => long.Parse(y.ToString())).Sum(); } } public static void Solve() { var N = int.Parse(Console.ReadLine()); var P = Console.ReadLine().Split().Select(long.Parse).ToArray(); var Q = P.Select(DigitSum); var prod = 1L; foreach (var item in Q) { prod *= item; } Console.WriteLine(DigitSum(prod)); } public static void Main() { var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false }; Console.SetOut(sw); Solve(); Console.Out.Flush(); } }