#include <bits/stdc++.h>
using namespace std;
int n, p;
int powe(int a, long long x) {
  if (x == 0) return 1;
  if (x & 1) {
    int take = powe(a, x - 1);
    return ((long long)take * a) % p;
  }
  int take = powe(a, x / 2);
  return ((long long)take * take) % p;
}
vector<vector<int> > mul(vector<vector<int> > a, vector<vector<int> > b) {
  vector<vector<int> > c(a.size(), vector<int>(b[0].size(), 0));
  for (int i = 0; i < a.size(); i++) {
    for (int j = 0; j < b[0].size(); j++) {
      for (int k = 0; k < a[0].size(); k++) {
        c[i][j] = ((long long)c[i][j] + (long long)a[i][k] * b[k][j]) % p;
      }
    }
  }
  return c;
}
vector<vector<int> > powv(vector<vector<int> > a, long long x) {
  if (x == 0) {
    vector<vector<int> > I(a.size(), vector<int>(a.size(), 0));
    for (int t = 0; t < a.size(); t++) I[t][t] = 1;
    return I;
  }
  if (x & 1) {
    vector<vector<int> > take = powv(a, x - 1);
    return mul(take, a);
  }
  vector<vector<int> > take = powv(a, x / 2);
  return mul(take, take);
}
int afterT(int sum, int f, int l, long long t) {
  int p3t = powe(3, t);
  vector<vector<int> > gn(2, vector<int>(2, 0));
  gn[0][0] = 3;
  gn[0][1] = gn[1][1] = 1;
  gn = powv(gn, t);
  int pfl = gn[0][1];
  int ret = (((long long)sum) * p3t) % p;
  ret = (ret - ((long long)f + l) * pfl) % p;
  ret = (ret + p) % p;
  return ret;
}
int F(long long x) {
  if (x == 0) return 0;
  vector<vector<int> > gn(2, vector<int>(2, 0));
  gn[0][0] = gn[0][1] = gn[1][0] = 1;
  gn = powv(gn, x - 1);
  return gn[0][0];
}
int main() {
  long long x, y;
  scanf("%d%I64d%I64d%d", &n, &x, &y, &p);
  int sum = 0, f = 0, l = 0, sl = 0;
  for (int i = 0; i < n; i++) {
    int tmp;
    scanf("%d", &tmp);
    if (i == 0) f = tmp;
    if (i == n - 1) l = tmp;
    if (n > 1 && i == n - 2) sl = tmp;
    sum = (sum + tmp) % p;
  }
  if (n == 1) {
    printf("%d\n", sum);
  } else {
    sum = afterT(sum, f, l, x);
    int tf = f;
    f = sl;
    f = ((long long)f * F(x)) % p;
    l = ((long long)l * F(x + 1)) % p;
    l = (l + f) % p;
    f = tf;
    sum = (afterT(sum, f, l, y));
    printf("%d\n", sum);
  }
  return 0;
}
