#include using namespace std; using ll=long long; ll modpow(ll a,ll n,int mod){ long long ret=1,t=a; while(n>0){ if(n&1)ret=ret*t%mod; t=t*t%mod; n/=2; } return ret; } int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); int N; ll M,B; cin>>N>>M>>B; M%=B; vector A(N,0ll); for(ll &i:A)cin>>i; ll ans=1; for(int i=0;i