#include <bits/stdc++.h>
const long maxn = 1000001;
struct sz {
  long long f[2][2];
};
long a[maxn], n;
long long sum, mod, x, y;
sz mul(sz a, sz b) {
  sz c;
  c.f[0][0] = c.f[0][1] = c.f[1][0] = c.f[1][1] = 0;
  for (int k = 0; k <= 1; k++)
    for (int i = 0; i <= 1; i++)
      for (int j = 0; j <= 1; j++)
        c.f[i][j] = (c.f[i][j] + a.f[i][k] * b.f[k][j]) % mod;
  return c;
}
sz power(sz a, long long x) {
  if (x == 1) return a;
  sz b = power(a, x >> 1);
  b = mul(b, b);
  if (x & 1) b = mul(b, a);
  return b;
}
int work() {
  if (n == 1) {
    printf("%d\n", a[n] % mod);
    return 0;
  }
  sz c, tmp;
  c.f[0][0] = 0;
  c.f[0][1] = 1;
  c.f[1][0] = 1;
  c.f[1][1] = 1;
  long long maxNum = a[n];
  if (x > 0) {
    tmp = power(c, x);
    maxNum = (a[n - 1] * tmp.f[1][0] + a[n] * tmp.f[1][1]) % mod;
  }
  c.f[0][0] = 3;
  c.f[0][1] = 0;
  c.f[1][0] = 1;
  c.f[1][1] = 1;
  long long ans = sum;
  if (x > 0) {
    tmp = power(c, x);
    ans = (sum * tmp.f[0][0] - (a[1] + a[n]) * tmp.f[1][0]) % mod;
  }
  if (y > 0) {
    tmp = power(c, y);
    ans = (ans * tmp.f[0][0] - (a[1] + maxNum) * tmp.f[1][0]) % mod;
  }
  if (ans < 0) ans += mod;
  printf("%d\n", ans);
  return 0;
}
int init() {
  scanf("%d%I64d%I64d%I64d", &n, &x, &y, &mod);
  sum = 0;
  for (long i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    sum += a[i];
  }
  sum %= mod;
  return 0;
}
int main() {
  init();
  work();
  return 0;
}
