using System; using System.Text; using System.Linq; using System.Collections; using System.Collections.Generic; using static System.Console; using static System.Math; namespace YukiCoder { public class Program { public static void Main(string[] args) { new Program().Solve(); } public void Solve() { int n = int.Parse(ReadLine()); int[] p = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray(); int k = 1; for (int i = 0; i < n; i++) { k *= p[i]; } while (k.ToString().Length != 1) { int sum = 0; for (int i = 0; i < k.ToString().Length; i++) { sum += int.Parse(k.ToString()[i].ToString()); } k += sum; } WriteLine(k); } } }