#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6 + 5;
long long x, y, mod, sum, pow2[65], finalsum, maxnum, tmp;
int a[maxn], tt;
struct matrix {
  int c11, c12, c21, c22;
} base, forsum, forbignum, xsum, ysum, sumxy[65], bignum[65], bignumx;
matrix make_mat(int a, int b, int c, int d) {
  matrix ans;
  ans.c11 = a;
  ans.c12 = b;
  ans.c21 = c;
  ans.c22 = d;
  return ans;
}
matrix zarb_mat(matrix a, matrix b) {
  matrix ans;
  ans.c11 = ((long long)b.c11 * a.c11 + (long long)b.c21 * a.c12) % mod;
  ans.c12 = ((long long)b.c12 * a.c11 + (long long)b.c22 * a.c12) % mod;
  ans.c21 = ((long long)b.c11 * a.c21 + (long long)b.c21 * a.c22) % mod;
  ans.c22 = ((long long)b.c12 * a.c21 + (long long)b.c22 * a.c22) % mod;
  return ans;
}
int main() {
  ios_base::sync_with_stdio(false);
  pow2[0] = 1;
  for (int i = 1; i <= 62; i++) pow2[i] = pow2[i - 1] * 2;
  int n;
  cin >> n >> x >> y >> mod;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    sum = (sum + a[i]) % mod;
  }
  forsum = make_mat(3, -1, 0, 1);
  base = make_mat(1, 0, 0, 1);
  forbignum = make_mat(0, 1, 1, 1);
  sumxy[0] = forsum;
  bignum[0] = forbignum;
  for (int i = 1; i <= 63; i++) {
    sumxy[i] = zarb_mat(sumxy[i - 1], sumxy[i - 1]);
    bignum[i] = zarb_mat(bignum[i - 1], bignum[i - 1]);
  }
  xsum = base;
  tmp = x;
  tt = 64 - 2;
  while (tmp > 0) {
    while (pow2[tt] > tmp) tt--;
    xsum = zarb_mat(xsum, sumxy[tt]);
    tmp -= pow2[tt];
  }
  bignumx = base;
  tmp = x;
  tt = 64 - 2;
  while (tmp > 0) {
    while (pow2[tt] > tmp) tt--;
    bignumx = zarb_mat(bignumx, bignum[tt]);
    tmp -= pow2[tt];
  }
  tmp = y;
  tt = 64 - 2;
  ysum = base;
  while (tmp > 0) {
    while (pow2[tt] > tmp) tt--;
    ysum = zarb_mat(ysum, sumxy[tt]);
    tmp -= pow2[tt];
  }
  long long mm;
  mm = ((long long)a[n - 1] * bignumx.c12) % mod;
  maxnum = ((long long)a[n] * bignumx.c22) % mod;
  maxnum = ((long long)maxnum + mm) % mod;
  finalsum =
      ((long long)sum * xsum.c11 + (long long)(a[1] + a[n]) * xsum.c12) % mod;
  finalsum = (((long long)finalsum * ysum.c11 +
               (long long)(a[1] + maxnum) * ysum.c12) %
                  mod +
              mod) %
             mod;
  cout << finalsum << endl;
  return 0;
}
