#include <bits/stdc++.h>
using namespace std;
const int maxn = 64;
const int INF = 1e9 + 9;
int bae;
struct matrix {
  int n;
  long long a[maxn][maxn];
  matrix() {}
  matrix(int n, int type = 0) : n(n) {
    for (int i = int(1); i <= int(n); ++i)
      for (int j = int(1); j <= int(n); ++j) a[i][j] = (type ? (i == j) : 0);
  }
  matrix(int n, int og[][maxn]) : n(n) {
    for (int i = int(1); i <= int(n); ++i)
      for (int j = int(1); j <= int(n); ++j) a[i][j] = og[i][j];
  }
  long long &operator()(const int &r, const int &c) { return a[r][c]; }
  matrix operator*(matrix &b) {
    matrix ans(n);
    for (int i = int(1); i <= int(n); ++i)
      for (int j = int(1); j <= int(n); ++j)
        for (int k = int(1); k <= int(n); ++k)
          ans(i, j) = (ans(i, j) + (a[i][k] * b(k, j) + bae + bae) % bae) % bae;
    return ans;
  }
  void set_to(const int &val) {
    for (int i = int(1); i <= int(n); ++i)
      for (int j = int(1); j <= int(n); ++j) a[i][j] = val;
  }
  void err() {
    for (int i = int(1); i <= int(n); ++i) {
      for (int j = int(1); j <= int(n); ++j) cerr << a[i][j] << " ";
      cerr << "\n";
    }
  }
};
int next_state[7][maxn] = {{0},
                           {0, 1, 0, 0, 0, 0},
                           {0, 0, 1, 0, 0, 0},
                           {0, -1, -1, 3, 0, 0},
                           {0, 0, 0, 0, 1, 1},
                           {0, 0, 0, 0, 1, 0}};
matrix matrix_pow(matrix &a, long long power) {
  matrix ans(a.n, 1);
  while (power) {
    if (power & 1) ans = ans * a;
    a = a * a, power >>= 1;
  }
  return ans;
}
int n, a[int(2e6)];
long long f_step, s_step;
int main() {
  scanf("%d %I64d %I64d %d", &n, &f_step, &s_step, &bae);
  matrix vec(5);
  for (int i = int(1); i <= int(n); ++i) {
    scanf("%d", &a[i]);
    vec(3, 1) = (vec(3, 1) + a[i]) % bae;
  }
  if (n == 1) {
    printf("%I64d\n", vec(3, 1));
    return 0;
  }
  vec(1, 1) = a[1], vec(2, 1) = a[n];
  vec(4, 1) = a[n], vec(5, 1) = a[n - 1];
  matrix next(5, next_state);
  next = matrix_pow(next, f_step);
  vec = next * vec;
  vec(2, 1) = vec(4, 1);
  next = matrix(5, next_state);
  next = matrix_pow(next, s_step);
  vec = next * vec;
  printf("%I64d\n", vec(3, 1));
  return 0;
}
