# -*- coding: utf-8 -*- if __name__ == '__main__': xN = list(map(int, input().split())) x = xN[0] N = xN[1] exponent_list = list(map(int, input().split())) sum_values = 0 for exponent in exponent_list: sum_values += pow(x, exponent) % 1000003 print(sum_values % 1000003)