用快读了,但是TLE了2个点
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define double long double
ll n,p,k,num[5000005];
ll read(){
ll f=1,x=0;
char ch;
ch=getchar();
while (ch>'9'||ch<'0'){
if (ch=='-') f=-1;
ch=getchar();
}
while (ch>='0'&&ch<='9'){
x=10*x+(ch-'0');
ch=getchar();
}
return x*f;
}
ll binpow(ll x,ll idx,ll mod){
ll res=1;
while(idx){
if (idx&1) res=(res*x)%mod;
x=(x*x)%mod;
idx>>=1;
}
return res%mod;
}
int main(){
n=read();
p=read();
k=read();
for (ll i=1;i<=n;i++){
ll t;
t=read();
ll x=binpow(t,p-2,p);
num[i]=(x%p+p)%p;
}
ll ans=0;
for (ll i=1;i<=n;i++){
ll tmp;
tmp=(binpow(k,i,p))*num[i];
ans+=tmp%p;
}
printf("%lld",ans%p);
return 0;
}