#include <bits/stdc++.h>
using namespace std;
const int maxn = 1000050;
int n, p;
int A[maxn];
struct Matrix {
  int a[7][7];
  Matrix operator*(Matrix b) {
    Matrix res;
    memset(res.a, 0, sizeof(res.a));
    for (int i = 0; i < 5; i++)
      for (int j = 0; j < 5; j++)
        for (int k = 0; k < 5; k++)
          res.a[i][j] =
              (res.a[i][j] + (a[i][k] * 1ll * b.a[k][j] + 2 * p) % p) % p;
    return res;
  }
} tmp, a, res;
void bp(long long b) {
  while (b) {
    if (b & 1) res = res * a;
    a = a * a;
    b >>= 1;
  }
}
long long c[4][6];
int main() {
  long long x, y;
  cin >> n >> x >> y >> p;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &A[i]);
    c[0][0] += A[i];
  }
  if (n == 1) {
    cout << A[1] % p;
    return 0;
  }
  c[0][1] = A[n];
  c[0][2] = A[n - 1];
  c[0][3] = A[1];
  c[0][4] = A[n];
  for (int i = 0; i < 5; i++) c[0][i] %= p;
  tmp.a[0][0] = 3;
  tmp.a[1][1] = tmp.a[3][3] = tmp.a[4][4] = 1;
  tmp.a[0][3] = -1, tmp.a[0][4] = -1;
  tmp.a[1][2] = tmp.a[2][1] = 1;
  for (int i = 0; i < 5; i++) {
    for (int j = 0; j < 5; j++) a.a[i][j] = tmp.a[i][j];
    res.a[i][i] = 1;
  }
  bp(x);
  for (int i = 0; i < 5; i++)
    for (int j = 0; j < 5; j++)
      c[1][i] = (c[1][i] + (c[0][j] * 1ll * res.a[i][j]) % p) % p;
  memset(res.a, 0, sizeof(res.a));
  for (int i = 0; i < 5; i++) {
    for (int j = 0; j < 5; j++) a.a[i][j] = tmp.a[i][j];
    res.a[i][i] = 1;
  }
  bp(y);
  c[1][4] = c[1][1];
  for (int i = 0; i < 5; i++)
    for (int j = 0; j < 5; j++)
      c[2][i] = (c[2][i] + (c[1][j] * 1ll * res.a[i][j]) % p) % p;
  cout << c[2][0];
  return 0;
}
