#include <bits/stdc++.h>
using namespace std;
template <class T>
T abs(T x) {
  return x > 0 ? x : (-x);
}
template <class T>
T sqr(T x) {
  return x * x;
}
const int maxn = 1000 * 1000 * 2;
const int BUBEN = 40;
long long fib[BUBEN];
int a[maxn];
int n;
long long X, Y;
long long P;
struct M {
  long long a[2][2];
  M() { memset(a, 0, sizeof(a)); }
  long long* operator[](int x) { return a[x]; }
  M operator*(M m) {
    M res;
    for (int i = 0; i < 2; ++i)
      for (int j = 0; j < 2; ++j)
        for (int k = 0; k < 2; ++k)
          res[i][j] = (res[i][j] + a[i][k] * m[k][j]) % P;
    return res;
  }
};
M pw(M x, long long y) {
  M res;
  res[0][0] = res[1][1] = 1;
  while (y) {
    if (y % 2LL == 1LL)
      res = res * x, --y;
    else
      x = x * x, y /= 2LL;
  }
  return res;
}
const double alpha = (1. + sqrt(5.)) * 0.5;
bool cmp(pair<long long, long long> p, pair<long long, long long> q) {
  if (X >= BUBEN - 2)
    return p.first * alpha + p.second > q.first * alpha + q.second;
  return p.first * fib[X + 1] + p.second * fib[X] >
         q.first * fib[X + 1] + q.second * fib[X];
}
int main() {
  fib[0] = 0;
  fib[1] = 1;
  for (int i = 2; i < BUBEN; ++i) fib[i] = fib[i - 1] + fib[i - 2];
  cin >> n >> X >> Y >> P;
  long long sum = 0;
  for (int i = 0; i < n; ++i) {
    scanf("%d", &a[i]);
    sum += a[i];
    sum %= P;
  }
  sort(a, a + n);
  if (0) {
    vector<int> v;
    for (int i = 0; i < n; ++i) v.push_back(a[i]);
    for (int i = 0; i < X; ++i) {
      vector<int> w;
      w.push_back(v[0]);
      for (int j = 1; j < ((int)(v).size()); ++j)
        w.push_back(v[j - 1] + v[j]), w.push_back(v[j]);
      v = w;
    }
    sort((v).begin(), (v).end());
    for (int i = 0; i < Y; ++i) {
      vector<int> w;
      w.push_back(v[0]);
      for (int j = 1; j < ((int)(v).size()); ++j)
        w.push_back(v[j - 1] + v[j]), w.push_back(v[j]);
      v = w;
    }
    long long res = 0;
    for (int i = 0; i < ((int)(v).size()); ++i) res += v[i];
    res %= P;
    cerr << res << "\n";
  }
  if (n == 1) {
    cout << (a[0] % P) << "\n";
    return 0;
  }
  long long l1 = a[0], r1 = a[n - 1];
  long long l2 = a[0];
  pair<long long, long long> _r2(-1, -1);
  for (int i = 0; i < n - 1; ++i) {
    long long x = a[i], y = a[i + 1];
    if (x < y) swap(x, y);
    pair<long long, long long> cur(x, y);
    if (cmp(cur, _r2)) _r2 = cur;
  }
  M mf;
  mf[0][0] = mf[0][1] = mf[1][0] = 1;
  M F = pw(mf, X);
  long long r2 = F[0][0] * (_r2.first % P) + F[0][1] * (_r2.second % P);
  r2 %= P;
  M m1;
  m1[0][0] = 3;
  m1[0][1] = (P - 1) % P;
  m1[1][1] = 1;
  M m2 = pw(m1, X);
  long long T1 = l1 + r1;
  long long T2 = l2 + r2;
  T1 %= P;
  T2 %= P;
  long long s0 = m2[0][0] * sum + m2[0][1] * (T1);
  s0 %= P;
  M m3 = pw(m1, Y);
  long long res = m3[0][0] * s0 + m3[0][1] * (T2);
  res %= P;
  res += P;
  res %= P;
  cout << res << "\n";
  return 0;
}
