#include <bits/stdc++.h>
using namespace std;
const int MAXN = (int)1e6 + 5;
int fibo[MAXN];
int arr[MAXN];
int f[MAXN];
long long x, y;
int mod;
int ans;
int n;
vector<vector<int> > I(int n) {
  vector<vector<int> > ret(n, vector<int>(n));
  for (int i = 0; i < n; ++i) {
    ret[i][i] = 1;
  }
  return ret;
}
vector<vector<int> > mlt(vector<vector<int> > a, vector<vector<int> > b) {
  int n = a.size();
  int m = a[0].size();
  int k = b[0].size();
  vector<vector<int> > ret(n, vector<int>(k));
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < k; ++j) {
      for (int p = 0; p < m; ++p) {
        ret[i][j] = (ret[i][j] + a[i][p] * 1ll * b[p][j] % mod + mod) % mod;
      }
    }
  }
  return ret;
}
vector<vector<int> > binPow(vector<vector<int> > V, long long n) {
  vector<vector<int> > ret = I(V.size());
  while (n) {
    if (n & 1) {
      ret = mlt(ret, V);
    }
    V = mlt(V, V);
    n >>= 1;
  }
  return ret;
}
void solve() {
  scanf("%d %lld %lld %d", &n, &x, &y, &mod);
  for (int i = 1; i <= n; ++i) {
    scanf("%d", &arr[i]);
  }
  if (n == 1) {
    printf("%d\n", arr[1] % mod);
    return;
  }
  f[0] = 1;
  for (int i = 1; i < MAXN; ++i) {
    f[i] = (f[i - 1] * 3ll - 1 + mod) % mod;
  }
  int fxy, fy;
  if (x + y < 10) {
    fxy = f[x + y];
  } else {
    vector<vector<int> > M = {{0, 1, 0}, {0, 3, -1}, {0, 0, 1}};
    M = binPow(M, x + y);
    fxy = (M[0][0] + M[0][1] * 2ll + M[0][2] + mod) % mod;
  }
  if (y < 10) {
    fy = f[y];
  } else {
    vector<vector<int> > M = {{0, 1, 0}, {0, 3, -1}, {0, 0, 1}};
    M = binPow(M, y);
    fy = (M[0][0] + M[0][1] * 2ll + M[0][2] + mod) % mod;
  }
  fibo[0] = 0;
  fibo[1] = 1;
  for (int i = 2; i < MAXN; ++i) {
    fibo[i] = (fibo[i - 1] + fibo[i - 2]) % mod;
  }
  int fibx, fibxp;
  if (x + 1 < 10) {
    fibx = fibo[x];
    fibxp = fibo[x + 1];
  } else {
    vector<vector<int> > M = {{0, 1}, {1, 1}};
    M = binPow(M, x + 1);
    fibx = M[0][0];
    fibxp = M[1][0];
  }
  for (int i = 1; i <= n; ++i) {
    int cur = fxy;
    if (i > 1 && i < n) {
      cur = (cur * 2ll - 1 + mod) % mod;
    }
    ans = (ans + arr[i] * 1ll * cur) % mod;
  }
  int mx = (arr[n] * 1ll * fibxp + arr[n - 1] * 1ll * fibx) % mod;
  int C = arr[n];
  ans = (ans - mx * 1ll * (fy * 2ll - 1 + mod) % mod + mod) % mod;
  ans = (ans + mx * 1ll * fy % mod) % mod;
  ans = (ans - C * 1ll * fy % mod + mod) % mod;
  ans = (ans + C * 1ll * (fy * 2ll - 1 + mod) % mod) % mod;
  printf("%d\n", ans);
}
int main() {
  int tt = 1;
  while (tt--) {
    solve();
  }
  return 0;
}
