#include #include #include #include using namespace std; using ll = long long; template using grid = vector>; #define REP(i,n) for(ll i=0;i<(ll)(n);i++) #define REPD(i,n) for(ll i=n-1;i>=0;i--) #define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++) #define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--) #define input(...) __VA_ARGS__; in(__VA_ARGS__) void print() { std::cout << std::endl; } template void print(Head&& head, Tail&&... tail) { std::cout << head << " "; print(std::forward(tail)...); } void in() { } template void in(Head&& head, Tail&&... tail) { cin >> head; in(std::forward(tail)...); } ll MOD = 1000000007; ll powmod(ll v, ll x) { if (x == 0) return 1; if (x % 2 == 0) { ll tmp = powmod(v, x / 2); return (tmp * tmp) % MOD; } else { return (powmod(v, x - 1) * v) % MOD; } } ll P, Q; ll e_value(ll k) { if (k == 1) { // return P / Q; return (P * powmod(Q, MOD - 2)) % MOD; } if (k % 2 == 0) { ll even = e_value(k / 2); ll odd = (1 - even + MOD) % MOD; return (even * even) % MOD + (odd * odd) % MOD; } else { ll even_one = e_value(1); ll even_other = e_value(k - 1); ll odd_one = (1 - even_one + MOD) % MOD; ll odd_other = (1 - even_other + MOD) % MOD; return (even_one * even_other) % MOD + (odd_one * odd_other) % MOD; } } int main() { ll input(n, m, k, p, q); P = p; Q = q; vector b(n); REP(i, n) cin >> b[i]; ll frn = e_value(k) % MOD; ll bck = (1 - frn + MOD) % MOD; ll prob = 0; REP(i, m) { (prob += b[i] * frn) %= MOD; } FOR(i, m, n - 1) { (prob += b[i] * bck) %= MOD; } print(prob % MOD); }