#include <bits/stdc++.h>
using namespace std;
int P = 0;
const int DIM = 1000005;
int arr[DIM];
struct str {
  int a[2][2];
  str() {
    a[0][0] = 0;
    a[0][1] = 0;
    a[1][0] = 0;
    a[1][1] = 0;
  }
  str(int x, int y, int z, int t) {
    a[0][0] = x;
    a[0][1] = y;
    a[1][0] = z;
    a[1][1] = t;
  }
  str operator*(str other) {
    str aux;
    for (int i = 0; i <= 1; ++i)
      for (int j = 0; j <= 1; ++j)
        for (int k = 0; k <= 1; ++k)
          aux.a[i][j] =
              (1LL * (*this).a[i][k] * other.a[k][j] + aux.a[i][j]) % P;
    return aux;
  }
} fib(1, 1, 1, 0), val(3, 0, -1, 1), idn(1, 0, 0, 1);
str lgput(str mat, long long n) {
  if (!n) return idn;
  str aux = lgput(mat, n >> 1);
  if ((n & 1) >= 0) aux = aux * aux;
  if ((n & 1) >= 1) aux = aux * mat;
  return aux;
}
int main(void) {
  int n, s = 0;
  long long x, y;
  scanf("%d %I64d %I64d %d", &n, &x, &y, &P);
  val.a[1][0] = P - 1;
  for (int i = 1; i <= n; ++i) scanf("%d", &arr[i]), s = (s + arr[i]) % P;
  sort(arr + 1, arr + n + 1);
  str ans(s, (arr[1] + arr[n]) % P, 0, 0);
  ans = ans * lgput(val, x);
  str aux(1, 0, 0, 0);
  aux = aux * lgput(fib, x);
  ans.a[0][1] =
      (1LL * aux.a[0][0] * arr[n] + arr[1] + 1LL * aux.a[0][1] * arr[n - 1]) %
      P;
  ans = ans * lgput(val, y);
  printf("%d\n", ans.a[0][0]);
  return 0;
}
