#include <bits/stdc++.h>
using namespace std;
const int n = 2;
struct Matrix {
  long long matrix[5][5];
};
Matrix unit;
int m;
long long cnt[1000005], MOD;
void initUnit() {
  memset(unit.matrix, 0, sizeof(unit.matrix));
  int i;
  for (i = 1; i <= n; i++) unit.matrix[i][i] = 1;
}
Matrix matrixMulti(Matrix x, Matrix y) {
  Matrix ret;
  int i, j, k;
  for (i = 1; i <= n; i++) {
    for (j = 1; j <= n; j++) {
      ret.matrix[i][j] = 0;
      for (k = 1; k <= n; k++) {
        ret.matrix[i][j] =
            (ret.matrix[i][j] + x.matrix[i][k] * y.matrix[k][j] % MOD) % MOD;
      }
      ret.matrix[i][j] = (ret.matrix[i][j] % MOD + MOD) % MOD;
    }
  }
  return ret;
}
Matrix matrixPow(Matrix x, long long k) {
  Matrix ret = unit;
  while (k) {
    if (k & 1) ret = matrixMulti(ret, x);
    x = matrixMulti(x, x);
    k >>= 1;
  }
  return ret;
}
long long mpow(long long a, long long p) {
  long long ret = 1;
  while (p) {
    if (p & 1) ret = (ret * a) % MOD;
    a = (a * a) % MOD;
    p = p >> 1;
  }
  return ret;
}
long long solve(long long minv, long long maxv, long long sum, long long k) {
  long long pw = mpow(3, k);
  long long ret = (2 * pw * sum % MOD - (pw - 1) * (minv + maxv) % MOD) % MOD;
  ret = (ret / 2) % MOD;
  return (ret % MOD + MOD) % MOD;
}
int main() {
  long long x, y, sum, minv, maxv;
  int i, j, k;
  initUnit();
  while (scanf("%d%I64d%I64d%I64d", &m, &x, &y, &MOD) != EOF) {
    for (i = 1, sum = 0; i <= m; i++) {
      scanf("%I64d", &cnt[i]);
      sum += cnt[i];
    }
    minv = cnt[1], maxv = cnt[m];
    if (m == 1) {
      printf("%I64d\n", sum % MOD);
    } else {
      MOD *= 2;
      sum = solve(minv % MOD, maxv % MOD, sum % MOD, x);
      Matrix mt;
      mt.matrix[1][1] = 0,
      mt.matrix[1][2] = mt.matrix[2][1] = mt.matrix[2][2] = 1;
      mt = matrixPow(mt, x);
      maxv = (mt.matrix[2][1] * cnt[m - 1] % MOD +
              mt.matrix[2][2] * cnt[m] % MOD) %
             MOD;
      sum = solve(minv % MOD, maxv % MOD, sum % MOD, y);
      MOD /= 2;
      printf("%I64d\n", sum % MOD);
    }
  }
  return 0;
}
