#include <bits/stdc++.h>
using namespace std;
int mod, n, s, val, res, sum, maxval;
long long x, y;
int a[2000000];
struct matrix {
  int a[4][4];
  int c[4][4];
  int len, i, j, k;
  void clear() { memset(a, 0, sizeof(a)); }
  void make_one() {
    for (i = 0; i < len; i++) a[i][i] = 1;
  }
  void operator*=(const matrix &b) {
    for (i = 0; i < len; i++)
      for (j = 0; j < len; j++) {
        c[i][j] = 0;
        for (k = 0; k < len; k++)
          (c[i][j] += (a[i][k] * 1ll * b.a[k][j]) % mod) %= mod;
      }
    for (i = 0; i < len; i++)
      for (j = 0; j < len; j++) a[i][j] = c[i][j];
  }
  void out() {
    for (int i = 0; i < len; i++)
      for (int j = 0; j < len; j++)
        printf("%d%c", a[i][j], j == len - 1 ? '\n' : ' ');
    puts("");
  }
} f, q, asd, ret;
int chr;
void get(int &x) {
  x = 0;
  for (chr = getchar(); chr >= '0' && chr <= '9'; chr = getchar())
    x = x * 10 + chr - '0';
}
int proceed(matrix &d, long long n) {
  ret.len = d.len;
  ret.clear();
  ret.make_one();
  asd = d;
  for (; n > 0;)
    if (n & 1)
      n--, ret *= asd;
    else
      n >>= 1, asd *= asd;
  return (ret.a[0][0] + ret.a[1][0]);
}
int threepow(long long n) {
  int ret = 1, asd = 3;
  for (; n > 0;)
    if (n & 1)
      n--, ret = (ret * 1ll * asd) % mod;
    else
      n >>= 1, asd = (asd * 1ll * asd) % mod;
  return ret;
}
int main() {
  scanf("%d", &n);
  cin >> x >> y;
  scanf("%d\n", &mod);
  for (int i = 0; i < n; i++) get(a[i]), (s += a[i]) %= mod;
  if (n == 1) {
    printf("%d\n", a[0] % mod);
    return 0;
  }
  (s -= a[0] + a[n - 1]) %= mod;
  (s += mod) %= mod;
  f.clear();
  f.len = 2;
  f.a[0][0] = f.a[1][0] = 1;
  f.a[1][1] = 3;
  q.clear();
  q.len = 2;
  q.a[0][0] = q.a[0][1] = q.a[1][0] = 1;
  sum = (threepow(x) * 1ll * s + proceed(f, x) * 1ll * (a[0] + a[n - 1])) % mod;
  proceed(q, x);
  maxval = (a[n - 1] * 1ll * ret.a[0][0] + a[n - 2] * 1ll * ret.a[0][1]) % mod;
  res = (threepow(y) * 1ll * (((sum - a[0] - maxval) % mod + mod) % mod) +
         proceed(f, y) * 1ll * (a[0] + maxval)) %
        mod;
  printf("%d\n", res);
  return 0;
}
