ll@n,@m,@b,@a[n],z=1; m%=b; rep(i,n)z=z*(powmod(m,a[i],b)+1)%b; wt(z);