#include #define Z 1000003 int x, N; long long int a; int getxn( int *xn, int n ); int main() { int xn[100]; long long int sum = 0; scanf("%d %d\n", &x, &N ); xn[0] = 1; for( int i = 0; i < N - 1 ; i++ ) { scanf("%d ", &a ); sum += getxn( xn, a ); sum = sum % Z; } scanf("%d\n", &a ); sum += getxn( xn, a ); sum = sum % Z; printf("%d\n", sum); return 0; } int getxn( int *xn, int n ) { static int r = 0; if( n <= r ) { return xn[n]; } for( int i = r+1; i <= n; i++ ) { xn[i] = ( xn[i-1] * x ) % Z; } r = n; return xn[n]; }