import java.io.BufferedReader; import java.io.InputStreamReader; import java.math.BigInteger; public class NO016 { public static void main(String[] args) { try { BufferedReader br = new BufferedReader(new InputStreamReader( System.in)); long[] xN = strTointArray(br.readLine()); BigInteger[] a = strTointArrayBigINt(br.readLine()); BigInteger x = new BigInteger(Long.toString(xN[0])); BigInteger ans = new BigInteger("0"); BigInteger mod = new BigInteger("1000003"); for (int i = 0; i < xN[1]; i++) { ans = ans.add(x.modPow(a[i], mod)); } System.out.println(ans); } catch (Exception e) { System.err.println("Error:" + e.getMessage()); } } static long[] strTointArray(String S) { String[] strArray = S.split(" "); long[] longArray = new long[strArray.length]; for (int i = 0; i < strArray.length; i++) { longArray[i] = Long.parseLong(strArray[i]); } return longArray; } static BigInteger[] strTointArrayBigINt(String S) { String[] strArray = S.split(" "); BigInteger[] longArray = new BigInteger[strArray.length]; for (int i = 0; i < strArray.length; i++) { longArray[i] = new BigInteger(strArray[i]); } return longArray; } }