#include<bits/stdc++.h>
using namespace std;
#define mod 1000007
#define inf 0x3f3f3f
#define re register
#define maxn 100000
#define int long long
int n,p,k;
int a[100010];
inline int read(){
int x=0,f=1;char ch=getchar();
while (ch<'0'||ch>'9') {if(ch=='-')f=-1; ch=getchar();}
while (ch>='0'&&ch<='9'){x=(x<<3)+(x<<1)+ch-'0'; ch=getchar();}
return x*f;
}
int l[100010],r[100010];
int s=1;
int kkk[100010];
void exgcd(int a,int b,int&g,int& x,int& y)
{
if(b==0)
{
g=a,x=1,y=0;
return ;
}
exgcd(b,a%b,g,x,y);
int t=x;
x=y;
y=t-(a/b)*x;
}
int g,x,y;
signed main()
{
// freopen("a.in","r",stdin);
// freopen("a.out","w",stdout);
// printf("%dM\n",(sizeof(dp) >> 20));
cin>>n>>p>>k;
// l[0]=1,r[n+1]=1;
for(re int i=1;i<=n;i++) a[i]=read(),s=1ll*s*a[i]%p;
for(re int i=1;i<=n;i++) l[i]=l[i-1]*a[i]%p;
for(re int i=n;i>=0;i--) r[i]=r[i+1]*a[i+1]%p;
kkk[1]=k;
for(re int i=2;i<=n;i++) kkk[i]=kkk[i-1]*k%p;
exgcd(s,p,g,x,y);
x=(p+x%p)%p;
int ans=0;
for(re int i=1;i<=n;i++)
ans=(ans+(1ll*kkk[i]*s/a[i]%p))%p;
cout<<ans*x%p;
return 0;
}
样例未过,求调