#include <bits/stdc++.h>
using namespace std;
template <class R>
inline void Readin(R &K) {
  K = 0;
  bool F = false;
  char C = getchar();
  while (C < '0' or C > '9') {
    if (C == '-') F = true;
    C = getchar();
  }
  while (C <= '9' and C >= '0')
    K = (K << 1) + (K << 3) + C - '0', C = getchar();
  if (F) K = -K;
}
const int MaxN = 1000000 + 10;
int N, Mod, A[MaxN], Sum;
long long X, Y;
struct Matrix {
  int A[2][2];
  Matrix(int a = 1, int b = 0, int c = 0, int d = 1) {
    A[0][0] = a;
    A[0][1] = b;
    A[1][0] = c;
    A[1][1] = d;
  }
};
inline Matrix operator*(Matrix A, Matrix B) {
  Matrix Ans = Matrix(0, 0, 0, 0);
  for (register int i = 0; i <= 1; ++i)
    for (register int j = 0; j <= 1; ++j)
      for (register int k = 0; k <= 1; ++k)
        (Ans.A[i][j] += 1ll * A.A[i][k] * B.A[k][j] % Mod) %= Mod;
  return Ans;
}
inline Matrix operator^(Matrix A, long long B) {
  Matrix Ans;
  while (B) {
    if (B & 1) Ans = Ans * A;
    A = A * A;
    B >>= 1;
  }
  return Ans;
}
Matrix Bas, Cal, Ans;
int main() {
  Readin(N);
  Readin(X);
  Readin(Y);
  Readin(Mod);
  for (register int i = 0; ++i <= N;) {
    Readin(A[i]);
    (Sum += A[i]) %= Mod;
  }
  if (N == 1) return not printf("%d\n", A[1] % Mod);
  sort(A + 1, A + 1 + N);
  Bas = Matrix(3, 0, Mod - (A[1] + A[N]) % Mod, 1);
  Cal = Matrix(Sum, 1, 0, 0);
  Ans = Cal * (Bas ^ X);
  Sum = Ans.A[0][0];
  Bas = Matrix(1, 1, 1, 0);
  Cal = Matrix(1, 0, 0, 0);
  Ans = Cal * (Bas ^ X);
  Bas = Matrix(3, 0,
               Mod - (((1ll * A[N] * Ans.A[0][0] % Mod +
                        1ll * A[N - 1] * Ans.A[0][1] % Mod) %
                       Mod) +
                      A[1]) %
                         Mod,
               1);
  Cal = Matrix(Sum, 1, 0, 0);
  Ans = Cal * (Bas ^ Y);
  return not printf("%d\n", Ans.A[0][0]);
}
