#include <bits/stdc++.h>
using namespace std;
long long x, y, p, a[1000005], sum, matrix[2][2], f[2];
int n;
void init() {
  scanf("%d%I64d%I64d%I64d\n", &n, &x, &y, &p);
  for (int i = 1; i <= n; i++) {
    scanf("%I64d", &a[i]);
    sum += a[i];
  }
  sum %= p;
}
void add() {
  int i, j;
  long long tmp[2];
  tmp[0] = tmp[1] = 0;
  for (i = 0; i < 2; i++)
    for (j = 0; j < 2; j++) {
      tmp[j] = (tmp[j] + f[i] * matrix[i][j] % p) % p;
    }
  f[0] = tmp[0];
  f[1] = tmp[1];
}
void mul() {
  int i, j, k;
  long long tmp[2][2];
  tmp[0][0] = tmp[0][1] = tmp[1][0] = tmp[1][1] = 0;
  for (i = 0; i < 2; i++)
    for (j = 0; j < 2; j++)
      for (k = 0; k < 2; k++)
        tmp[i][k] = (tmp[i][k] + matrix[i][j] * matrix[j][k] % p) % p;
  for (i = 0; i < 2; i++)
    for (j = 0; j < 2; j++) matrix[i][j] = tmp[i][j];
}
void calc(long long n) {
  while (n) {
    if (n & 1) add();
    mul();
    n >>= 1;
  }
}
void work() {
  if (n == 1) {
    printf("%I64d\n", a[1] % p);
    return;
  }
  matrix[0][0] = 3;
  matrix[0][1] = 1;
  matrix[1][0] = 0;
  matrix[1][1] = 1;
  f[0] = 1;
  f[1] = 0;
  calc(x);
  sum = (sum * f[0] % p - ((a[1] + a[n]) % p * f[1]) % p + p) % p;
  matrix[0][0] = 0;
  matrix[0][1] = matrix[1][0] = matrix[1][1] = 1;
  f[0] = 0;
  f[1] = 1;
  calc(x);
  a[n] = (f[0] * a[n - 1] % p + f[1] * a[n] % p) % p;
  matrix[0][0] = 3;
  matrix[0][1] = 1;
  matrix[1][0] = 0;
  matrix[1][1] = 1;
  f[0] = 1;
  f[1] = 0;
  calc(y);
  sum = (sum * f[0] % p - ((a[1] + a[n]) % p * f[1]) % p + p) % p;
  printf("%I64d\n", sum);
}
int main() {
  init();
  work();
  return 0;
}
