#include <bits/stdc++.h>
using namespace std;
long long g[2][2];
long long f[2];
int A[1100000];
int n;
long long mo, n1, n2, s, Max, rest, x, y, z, ss;
int read() {
  bool flag = false;
  char ch;
  int res = 0;
  while (true) {
    ch = getchar();
    if (ch >= '0' && ch <= '9') {
      flag = true;
      res = res * 10 + ch - '0';
    } else if (flag)
      return res;
  }
}
void Cheng1(long long aa[], long long bb[][2]) {
  long long cc[2];
  for (int i = 0; i < 2; ++i) {
    cc[i] = 0;
    for (int j = 0; j < 2; ++j) cc[i] = (cc[i] + aa[j] * bb[j][i]) % mo;
  }
  for (int i = 0; i < 2; ++i) aa[i] = cc[i];
}
void Cheng2_self(long long aa[][2]) {
  long long cc[2][2];
  for (int i = 0; i < 2; ++i)
    for (int j = 0; j < 2; ++j) {
      cc[i][j] = 0;
      for (int k = 0; k < 2; ++k)
        cc[i][j] = (cc[i][j] + aa[i][k] * aa[k][j]) % mo;
    }
  for (int i = 0; i < 2; ++i)
    for (int j = 0; j < 2; ++j) aa[i][j] = cc[i][j];
}
long long Find_max() {
  f[0] = A[n - 1];
  f[1] = A[n];
  g[0][0] = 1;
  g[0][1] = 1;
  g[1][0] = 1;
  g[1][1] = 2;
  x = n1 / 2;
  for (; x; x /= 2) {
    if (x & 1) Cheng1(f, g);
    Cheng2_self(g);
  }
  if (n1 % 2 == 1)
    return (f[0] + f[1]) % mo;
  else
    return f[1];
}
long long Calc_sum(long long nn) {
  g[0][0] = 3;
  g[0][1] = 0;
  g[1][0] = mo - 1;
  g[1][1] = 1;
  f[0] = s;
  f[1] = rest % mo;
  x = nn;
  for (; x; x /= 2) {
    if (x & 1) Cheng1(f, g);
    Cheng2_self(g);
  }
  return (f[0] + mo) % mo;
}
int main() {
  scanf("%d%I64d%I64d%d", &n, &n1, &n2, &mo);
  s = 0;
  for (int i = 1; i <= n; ++i) {
    A[i] = read();
    s = s + A[i];
    s %= mo;
  }
  if (n == 1) {
    printf("%d\n", A[1] % mo);
    return 0;
  }
  Max = Find_max();
  rest = A[1] + A[n];
  rest %= mo;
  ss = Calc_sum(n1);
  s = ss;
  rest = A[1] + Max;
  rest %= mo;
  ss = Calc_sum(n2);
  printf("%I64d\n", ss);
  return 0;
}
