#include <bits/stdc++.h>
const int N = (int)1e6 + 123;
const double eps = 1e-6;
using namespace std;
int mod;
struct matrix {
  int n, m;
  int a[100][100];
  matrix() {
    n = m = 0;
    memset(a, 0, sizeof a);
  }
  matrix operator*(matrix b) {
    matrix res;
    res.n = n, res.m = b.m;
    for (int i = 1; i <= n; i++)
      for (int j = 1; j <= b.m; j++)
        for (int k = 1; k <= m; k++)
          res.a[i][j] = (res.a[i][j] + (1ll * a[i][k] * b.a[k][j]) % mod) % mod;
    return res;
  }
};
matrix binpow(matrix a, long long b) {
  matrix res;
  res.n = a.n, res.m = a.m;
  memset(res.a, 0, sizeof res.a);
  for (int i = 1; i <= res.n; i++) res.a[i][i] = 1;
  while (b) {
    if (b & 1) res = res * a;
    a = a * a;
    b >>= 1;
  }
  return res;
}
int n;
long long x, y;
int A[N];
matrix a, b;
matrix c, d;
int ans;
int main() {
  scanf("%d%I64d%I64d%d", &n, &x, &y, &mod);
  a.n = a.m = 2;
  a.a[1][1] = a.a[2][1] = 1;
  a.a[1][2] = 0, a.a[2][2] = 3;
  b.n = 2, b.m = 1;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &A[i]);
    if (i == 1 || i == n)
      b.a[1][1] = (b.a[1][1] + A[i]) % mod;
    else
      b.a[2][1] = (b.a[2][1] + A[i]) % mod;
  }
  if (n == 1) {
    cout << A[1] % mod;
    return 0;
  }
  a = binpow(a, x);
  b = a * b;
  a.n = a.m = 2;
  a.a[1][1] = a.a[2][1] = 1;
  a.a[1][2] = 0, a.a[2][2] = 3;
  b.a[2][1] = (b.a[1][1] + b.a[2][1]) % mod;
  b.a[1][1] = A[1];
  c.n = c.m = 2;
  c.a[1][1] = 0;
  c.a[2][1] = c.a[1][2] = c.a[2][2] = 1;
  d.n = 2, d.m = 1;
  d.a[1][1] = A[n - 1];
  d.a[2][1] = A[n];
  c = binpow(c, x);
  d = c * d;
  b.a[1][1] = (b.a[1][1] + d.a[2][1]) % mod;
  b.a[2][1] = (b.a[2][1] - b.a[1][1]) % mod;
  if (b.a[2][1] < 0) b.a[2][1] += mod;
  a = binpow(a, y);
  b = a * b;
  ans = (b.a[1][1] + b.a[2][1]) % mod;
  printf("%d", ans);
  return 0;
}
