#include using namespace std; struct R{ //de>0 long long nu,de; bool operator<(const R& other) const { return (__int128)nu*other.de<(__int128)de*other.nu; } bool operator==(const R& other) const { return (__int128)nu*other.de==(__int128)de*other.nu; } R operator+(const R& other) const { return {nu*other.de+de*other.nu,de*other.de}; } }; int main(void){ int n; long long a,b; cin>>n>>a>>b; R ans={0,1}; for(int i=0;i<=n;i++){ long long k; cin>>k; long long ta=1,tb=1; for(int j=0;j<=i;j++){ ta*=a; tb*=b; } ans=ans+(R){k*(tb-ta),i+1}; } if(ans.nu==0){ cout<<0<