#include <bits/stdc++.h>
using namespace std;
typedef long long M[2][2];
int n, p;
long long x, y;
void Mul(M &A, M B) {
  M C;
  for (int i = 0; i < 2; i++)
    for (int j = 0; j < 2; j++) {
      C[i][j] = 0;
      for (int k = 0; k < 2; k++) C[i][j] += A[i][k] * B[k][j];
    }
  for (int i = 0; i < 2; i++)
    for (int j = 0; j < 2; j++) A[i][j] = C[i][j] % p;
}
void Pow(M &A, long long k) {
  M B;
  B[0][0] = B[1][1] = 1;
  B[0][1] = B[1][0] = 0;
  while (k) {
    if (k & 1) Mul(B, A);
    Mul(A, A);
    k >>= 1;
  }
  for (int i = 0; i < 2; i++)
    for (int j = 0; j < 2; j++) A[i][j] = B[i][j];
}
int main() {
  while (~scanf("%d%I64d%I64d%d", &n, &x, &y, &p)) {
    int mn, mx, smx, sum = 0;
    for (int i = 1; i <= n; i++) {
      int temp;
      scanf("%d", &temp);
      temp %= p;
      sum += temp;
      if (sum >= p) sum -= p;
      if (i == 1) mn = temp;
      if (i == n - 1) smx = temp;
      if (i == n) mx = temp;
    }
    if (n == 1)
      printf("%d\n", mn);
    else {
      if (x == 0) swap(x, y);
      M A;
      A[0][0] = A[0][1] = 1, A[1][0] = 0, A[1][1] = 3 % p;
      Pow(A, x - 1);
      int a = (A[0][0] + A[0][1] * 3 % p + 1) % p, b = A[1][1] * 3 % p;
      sum = ((long long)a * (mn + mx) % p +
             (long long)((sum - mn - mx) % p + p) % p * b % p) %
            p;
      A[0][0] = A[0][1] = A[1][0] = 1, A[1][1] = 0;
      Pow(A, x);
      a = A[0][0], b = A[1][0];
      mx = ((long long)a * mx % p + (long long)b * smx % p) % p;
      if (y == 0)
        a = 1, b = 1;
      else {
        A[0][0] = A[0][1] = 1, A[1][0] = 0, A[1][1] = 3 % p;
        Pow(A, y - 1);
        a = (A[0][0] + A[0][1] * 3 % p + 1) % p, b = A[1][1] * 3 % p;
      }
      sum = ((long long)a * (mn + mx) % p +
             (long long)((sum - mn - mx) % p + p) % p * b % p) %
            p;
      printf("%d\n", sum);
    }
  }
  return 0;
}
