#include <bits/stdc++.h>
using namespace std;
const int MAX_N = (int)1e6 + 10;
int n, mod;
long long x, y;
int a[MAX_N];
int pow_mod(int a, long long b) {
  int ret = 1;
  for (; b; b >>= 1, a = (long long)a * a % mod) {
    if (b & 1) {
      ret = (long long)ret * a % mod;
    }
  }
  return ret;
}
struct Matrix {
  int c[2][2];
  Matrix() { c[0][0] = c[0][1] = c[1][0] = c[1][1] = 0; }
};
Matrix operator*(const Matrix &a, const Matrix &b) {
  Matrix c;
  for (int k = 0; k < 2; ++k) {
    for (int i = 0; i < 2; ++i) {
      for (int j = 0; j < 2; ++j) {
        c.c[i][j] = (c.c[i][j] + (long long)a.c[i][k] * b.c[k][j] % mod) % mod;
      }
    }
  }
  return c;
}
Matrix pow_mod(Matrix a, long long b) {
  Matrix ret;
  ret.c[0][0] = ret.c[1][1] = 1;
  for (; b; b >>= 1, a = a * a) {
    if (b & 1) {
      ret = ret * a;
    }
  }
  return ret;
}
int calc() {
  Matrix tran_mat;
  tran_mat.c[0][0] = tran_mat.c[0][1] = tran_mat.c[1][0] = 1;
  tran_mat = pow_mod(tran_mat, x);
  return ((long long)tran_mat.c[0][0] * a[n - 1] +
          (long long)tran_mat.c[1][0] * a[n - 2]) %
         mod;
}
int main() {
  cin >> n >> x >> y >> mod;
  int s = 0;
  for (int i = 0; i < n; ++i) {
    scanf("%d", a + i);
    s = (s + a[i] % mod) % mod;
  }
  if (n == 1) {
    return printf("%d\n", a[0] % mod), 0;
  }
  Matrix tran_mat;
  tran_mat.c[0][1] = tran_mat.c[1][1] = 1;
  tran_mat.c[0][0] = 3;
  tran_mat = pow_mod(tran_mat, x);
  s = ((long long)s * tran_mat.c[0][0] -
       tran_mat.c[0][1] * 1LL * (a[0] + a[n - 1])) %
      mod;
  tran_mat.c[0][1] = tran_mat.c[1][1] = 1;
  tran_mat.c[0][0] = 3;
  tran_mat.c[1][0] = 0;
  tran_mat = pow_mod(tran_mat, y);
  s = ((long long)s * tran_mat.c[0][0] -
       tran_mat.c[0][1] * 1LL * (a[0] + calc())) %
      mod;
  printf("%d\n", (s + mod) % mod);
}
