#include <bits/stdc++.h>
using namespace std;
void Helltaker() {
  ios_base::sync_with_stdio(0);
  cin.tie(0), cout.tie(0);
}
const long long Mxn = 2e5 + 7;
const long long Mod = 1e9 + 7;
const long long Inf = 1e18 + 7;
long long M, x, y, p, A;
long long Sum, First, Last, Mx1, Mx2;
vector<vector<long long>> One() {
  vector<vector<long long>> Result(13, vector<long long>(13, false));
  for (int i = 1; i <= 5; i++) Result[i][i] = true;
  return Result;
}
vector<vector<long long>> Mult(vector<vector<long long>> A,
                               vector<vector<long long>> B) {
  vector<vector<long long>> Result(13, vector<long long>(13, false));
  for (int i = 1; i <= 5; i++) {
    for (int j = 1; j <= 5; j++) {
      for (int q = 1; q <= 5; q++) {
        Result[i][j] =
            (((Result[i][j] + p) % p) + ((A[i][q] * B[q][j]) % p)) % p;
      }
    }
  }
  return Result;
}
vector<vector<long long>> Binpow(vector<vector<long long>> A, long long P) {
  if (!P)
    return One();
  else if (P % 2)
    return Mult(A, Binpow(A, P - 1));
  else {
    vector<vector<long long>> first = Binpow(A, P / 2);
    return Mult(first, first);
  }
}
int main() {
  Helltaker();
  cin >> M >> x >> y >> p;
  for (int i = 1; i <= M; i++) {
    cin >> A;
    if (i == 1) First = A;
    if (i == M - 1) Mx2 = A;
    if (i == M) Mx1 = Last = A;
    Sum = (Sum + A) % p;
  }
  vector<vector<long long>> Ans(13, vector<long long>(13, false));
  Ans[1][1] = 3, Ans[1][2] = Ans[1][3] = -1;
  Ans[2][2] = Ans[3][3] = Ans[4][5] = Ans[5][5] = Ans[5][4] = true;
  Ans = Binpow(Ans, x);
  Sum = (Sum * Ans[1][1]) % p;
  Sum += (First * Ans[1][2]) % p;
  Sum = (Sum + p) % p;
  Sum += (Last * Ans[1][3]) % p;
  Sum = (Sum + p) % p;
  Mx1 = (Ans[5][5] * Mx1) % p;
  Mx1 += (Ans[5][4] * Mx2) % p;
  Ans[1][1] = 3, Ans[1][2] = Ans[1][3] = -1;
  Ans = Binpow(Ans, y);
  Last = Mx1;
  Sum = (Ans[1][1] * Sum) % p;
  Sum += (First * Ans[1][2]) % p;
  Sum = (Sum + p) % p;
  Sum += (Ans[1][3] * Last) % p;
  Sum = (Sum + p) % p;
  cout << Sum;
}
