#include <bits/stdc++.h>
using namespace std;
const int MaxSize = 5;
long long mod;
struct Matrix {
  long long arr[MaxSize][MaxSize];
};
Matrix MUL(Matrix &a, Matrix &b) {
  Matrix res;
  for (int i = 0; i < MaxSize; i++)
    for (int j = 0; j < MaxSize; j++) {
      res.arr[i][j] = 0;
      for (int k = 0; k < MaxSize; k++) {
        long long sum = a.arr[i][k] * b.arr[k][j];
        sum %= mod;
        res.arr[i][j] += sum;
        res.arr[i][j] %= mod;
      }
    }
  return res;
}
Matrix Identity() {
  Matrix res;
  for (int i = 0; i < MaxSize; i++)
    for (int j = 0; j < MaxSize; j++) res.arr[i][j] = (i == j);
  return res;
}
Matrix Power(Matrix a, long long x) {
  Matrix res = Identity();
  while (x) {
    if (x & 1) {
      res = MUL(res, a);
    }
    a = MUL(a, a);
    x >>= 1ll;
  }
  return res;
}
int arr[1000100];
int main() {
  Matrix t = {1, 1, 0, 0, 0, 1, 0, 0, 0, 0,  0,  0, 1,
              0, 0, 0, 0, 0, 1, 0, 0, 0, -1, -1, 3};
  long long n, x, y;
  cin >> n >> x >> y >> mod;
  long long sum = 0;
  for (int i = 0; i < n; i++) {
    scanf("%d", &arr[i]);
    sum = (sum + arr[i]) % mod;
  }
  Matrix a;
  if (n == 1) {
    cout << arr[0] % mod;
    return 0;
  }
  memset(a.arr, 0, sizeof a.arr);
  a.arr[0][0] = arr[n - 1], a.arr[1][0] = arr[n - 2], a.arr[2][0] = arr[0],
  a.arr[3][0] = arr[n - 1], a.arr[4][0] = sum;
  Matrix res = Power(t, x);
  res = MUL(res, a);
  res.arr[3][0] = res.arr[0][0];
  Matrix res2 = Power(t, y);
  res = MUL(res2, res);
  if (res.arr[4][0] < 0) res.arr[4][0] += mod;
  cout << res.arr[4][0];
  return 0;
}
