using System; using System.Collections; using System.Collections.Generic; using System.Text; public class Program { public void Proc() { Reader.IsDebug = false; int[] inpt = Reader.GetInt(); int baseNum = inpt[0]; int itemCount = inpt[1]; int[] powList = Reader.GetInt(); long ans = 0; foreach (int pow in powList) { ans += this.GetSubTotal(baseNum, pow); ans = ans % Div; } Console.WriteLine(ans); } private long GetSubTotal(int baseNum, int pow) { if(dic[pow] > 0) { return dic[pow]; } long ans = 1; if(pow <= 4) { ans = (long)Math.Pow(baseNum, pow) % Div; } else { int half = pow / 2; ans = this.GetSubTotal(baseNum, half); ans = ans * this.GetSubTotal(baseNum, pow - half) % Div; } dic[pow] = ans; return ans; } private long[] dic = new long[100000000 + 1]; private int Div = 1000003; public class Reader { private static String InitText = @" "; private static System.IO.StringReader sr = null; public static bool IsDebug = true; public static string ReadLine() { if(IsDebug) { if(sr == null) { sr = new System.IO.StringReader(InitText.Trim()); } return sr.ReadLine(); } else { return Console.ReadLine(); } } public static int[] GetInt(char delimiter = ' ') { string[] inpt = ReadLine().Split(delimiter); int[] ret = new int[inpt.Length]; for(int i=0; i