#include using namespace std; // 定積分は微分するとf(x)になるg(x)(ただし定数項=0)にてg(B)-g(A)で求まるらしい int main(){ #define int long long int n,x,y; cin >> n >> x >> y; vector> A(n+1); for (int i(0);auto& [a,b]:A) (cin>>a),b = ++i; long double r = 0; for (int i(0),k(x);i <= n;++i,k*=x) r -= ((long double)A[i].first*k)/A[i].second; for (int i(0),k(y);i <= n;++i,k*=y) r += ((long double)A[i].first*k)/A[i].second; cout << floor(r) << endl; }