#include <bits/stdc++.h>
using namespace std;
int n, MOD;
int a[1000000];
long long x, y;
int mat[2][2], res[2][2];
long long tmp[2][2];
void matMul(int (&a)[2][2], int (&b)[2][2]) {
  for (int i = 0; i < (int)(2); ++i)
    for (int j = 0; j < (int)(2); ++j) {
      tmp[i][j] = 0;
      for (int k = 0; k < (int)(2); ++k)
        tmp[i][j] += (long long)a[i][k] * b[k][j];
    }
  for (int i = 0; i < (int)(2); ++i)
    for (int j = 0; j < (int)(2); ++j) a[i][j] = tmp[i][j] % MOD;
}
void matPow(long long x) {
  for (int i = 0; i < (int)(2); ++i)
    for (int j = 0; j < (int)(2); ++j) res[i][j] = i == j;
  while (x) {
    if (x & 1) matMul(res, mat);
    x >>= 1;
    matMul(mat, mat);
  }
}
int binPow(long long x, long long p) {
  long long ret = 1;
  while (p) {
    if (p & 1) ret = ret * x % MOD;
    p >>= 1;
    x = x * x % MOD;
  }
  return (int)ret;
}
int go(long long x) {
  if (x == 0) return 1;
  if (x == 1) return 4;
  int ret = go((x - 1) / 2);
  ret = (long long)ret * (binPow(3, (x + 1) / 2) + 1) % MOD;
  if (!(x & 1)) {
    ret = (3ll * ret + 1) % MOD;
  }
  return ret;
}
int calc(long long x) {
  if (x == 0) return 1;
  int ret = binPow(3, x);
  ret -= go(x - 1);
  if (ret < 0) ret += MOD;
  return ret;
}
int main() {
  scanf("%d%I64d%I64d%d", &n, &x, &y, &MOD);
  for (int i = 0; i < (int)(n); ++i) scanf("%d", a + i);
  if (n == 1) {
    cout << a[0] % MOD << endl;
    return 0;
  }
  long long ans = 0, mul = calc(x);
  for (int i = 0; i < (int)(n); ++i) {
    ans += a[i];
  }
  ans %= MOD;
  ans *= 2 * mul - 1;
  ans -= (a[0] + a[n - 1]) * (mul - 1);
  ans %= MOD;
  if (y) {
    for (int i = 0; i < (int)(2); ++i)
      for (int j = 0; j < (int)(2); ++j) mat[i][j] = i | j;
    matPow(x);
    long long mnmx = a[0] + (long long)a[n - 2] * res[0][1] +
                     (long long)a[n - 1] * res[1][1];
    mnmx %= MOD;
    mul = calc(y);
    ans *= 2 * mul - 1;
    ans -= mnmx * (mul - 1);
  }
  ans %= MOD;
  if (ans < 0) ans += MOD;
  cout << ans << endl;
  return 0;
}
