#include using namespace std; using ll = long long; int main(){ ios::sync_with_stdio(false); cin.tie(0); int n, a, b; cin >> n >> a >> b; ll lc = 1; for(int i = 1; i <= n + 1; i++) lc = lcm(lc, i); ll am = 1, bm = 1, v, ans = 0; for(int i = 0; i <= n; i++){ cin >> v; am *= a, bm *= b; ans += (v * (bm - am)) * lc / (i + 1); } cout << ans / lc << '\n'; }