#include <bits/stdc++.h>
int n, i, j, h;
long long fir, sec, p, sum, deg;
long long res, res2, x, d;
long long a[3][3], m[3][3], zz[3][3];
int arr[1000010];
void mul(long long a[3][3], long long b[3][3]) {
  for (i = 1; i <= 2; i++) {
    for (j = 1; j <= 2; j++) {
      zz[i][j] = 0;
      for (h = 1; h <= 2; h++) {
        zz[i][j] = (zz[i][j] + a[i][h] * b[h][j]) % p;
      }
    }
  }
}
long long doit(long long deg, long long x, long long mod) {
  long long res = 1;
  while (deg > 0) {
    if (deg % 2 == 0) {
      deg = deg / 2;
      x = (x * x) % mod;
    } else {
      deg--;
      res = (res * x) % mod;
    }
  }
  return res;
}
void find(long long tt) {
  res = doit(tt, 3, p);
  res2 = doit(tt, 3, p * 2) - 1;
  res2 = res2 / 2;
  sum = (sum * res + p - (d * res2) % p) % p;
}
int main() {
  scanf("%d%I64d%I64d%I64d", &n, &fir, &sec, &p);
  sum = 0;
  for (i = 1; i <= n; i++) {
    scanf("%d", &arr[i]);
    sum = (sum + arr[i]) % p;
  }
  if (n == 1) {
    printf("%I64d", sum);
    return 0;
  }
  deg = fir / 2;
  a[1][1] = 1;
  a[1][2] = 1;
  a[2][1] = 1;
  a[2][2] = 2;
  m[1][1] = 1;
  m[2][2] = 1;
  while (deg > 0) {
    if (deg % 2 == 0) {
      deg = deg / 2;
      mul(a, a);
      for (i = 1; i <= 2; i++) {
        for (j = 1; j <= 2; j++) a[i][j] = zz[i][j];
      }
    } else {
      deg--;
      mul(a, m);
      for (i = 1; i <= 2; i++) {
        for (j = 1; j <= 2; j++) m[i][j] = zz[i][j];
      }
    }
  }
  d = arr[1] + arr[n];
  find(fir);
  if (fir % 2 == 1) {
    d = (arr[1] + (m[1][1] + m[1][2]) * arr[n - 1] +
         (m[2][1] + m[2][2]) * arr[n]) %
        p;
  } else {
    d = (arr[1] + m[1][2] * arr[n - 1] + m[2][2] * arr[n]) % p;
  }
  find(sec);
  printf("%I64d", sum);
  return 0;
}
