program main
  implicit none
  integer*8::x,N,total,i
  integer*8,allocatable::a(:)
  integer::memo(0:100000000)
  integer,parameter::modulo=1000003
  data memo/100000001*0/,total/0/
  read *,x,N
  allocate(a(N))
  read *,a
  memo(0) = 1
  memo(1) = x
  do i=1,N
     total = total + power(x,a(i),memo)
  end do
  print '(i0)',MOD(total,modulo)
contains
  recursive function power(x,p,memo) result(y)
    integer*8::x,y
    integer*8::p
    integer,parameter::modulo=1000003
    integer::memo(0:100000000)

    if(memo(p).ne.0) then
       y = memo(p)
    else if(MOD(p,2).eq.0) then
       y = mod(power(x,p/2,memo)*power(x,p/2,memo),modulo)
       memo (p) = y
    else
       y = mod(power(x,p/2+1,memo)*power(x,p/2,memo),modulo)
       memo (p) = y
    end if
  end function power
end program