#include <bits/stdc++.h>
using namespace std;
class Matrix {
 public:
  long long **data;
  int n;
  int mod;
  Matrix(int sz, int module) : mod(module), n(sz) {
    data = new long long *[n];
    for (int i = 0; i < n; i++) data[i] = new long long[n];
  }
  Matrix(const Matrix &other) : n(other.n), mod(other.mod) {
    data = new long long *[n];
    for (int i = 0; i < n; i++) {
      data[i] = new long long[n];
      for (int j = 0; j < n; j++) data[i][j] = other.data[i][j];
    }
  }
  Matrix operator=(const Matrix &other) {
    for (int i = 0; i < n; i++)
      for (int j = 0; j < n; j++) data[i][j] = other.data[i][j];
    return *this;
  }
  Matrix power(long long k) {
    Matrix ret(n, mod);
    for (int i = 0; i < n; i++)
      for (int j = 0; j < n; j++) ret.data[i][j] = i == j;
    Matrix a = *this;
    while (k) {
      if (k & 1) ret = ret * a;
      a = a * a;
      k >>= 1;
    }
    return ret;
  }
  Matrix operator*(const Matrix &other) {
    Matrix ret(n, mod);
    for (int i = 0; i < n; i++)
      for (int j = 0; j < n; j++) {
        ret.data[i][j] = 0;
        for (int k = 0; k < n; k++)
          ret.data[i][j] =
              (ret.data[i][j] + data[i][k] * other.data[k][j]) % mod;
      }
    return ret;
  }
  void print() {
    for (int i = 0; i < n; i++)
      for (int j = 0; j < n; j++) cout << data[i][j] << " \n"[j == n - 1];
  }
  ~Matrix() {
    for (int i = 0; i < n; i++) delete[] data[i];
    delete[] data;
  }
};
int a[1005000];
int main() {
  long long n, x, y, mod;
  cin.sync_with_stdio(false);
  cin >> n >> x >> y >> mod;
  long long mid = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    mid += a[i];
  }
  if (n == 1) {
    cout << a[0] % mod << endl;
    return 0;
  }
  mid -= a[0] + a[n - 1];
  mid %= mod;
  Matrix fib(2, mod);
  fib.data[0][0] = 0;
  fib.data[0][1] = fib.data[1][0] = fib.data[1][1] = 1;
  Matrix conv(3, mod);
  for (int i = 0; i < 3; i++)
    for (int j = 0; j < 3; j++) {
      conv.data[i][j] = 0;
      if (i == j) conv.data[i][j] = 1 + (i == 1) + (j == 1);
      if (i == 0 and j == 1 or i == 2 and j == 1) conv.data[i][j] = 1;
    }
  Matrix firstMove(conv);
  firstMove = firstMove.power(x);
  long long sum = 0;
  long long left = a[0], right = a[n - 1];
  mid = (left * firstMove.data[0][1] + mid * firstMove.data[1][1] +
         right * firstMove.data[2][1]) %
        mod;
  sum = (left + right + mid) % mod;
  fib = fib.power(x);
  long long mx = (a[n - 2] * fib.data[0][1] + a[n - 1] * fib.data[1][1]) % mod;
  right = mx;
  mid = sum - left - right;
  Matrix secondMove(conv);
  secondMove = secondMove.power(y);
  mid = (left * secondMove.data[0][1] + mid * secondMove.data[1][1] +
         right * secondMove.data[2][1]) %
        mod;
  sum = (left + right + mid) % mod;
  while (sum < 0) sum += mod;
  cout << sum << endl;
  return 0;
}
