#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e6 + 5;
long long MOD;
int a[MAXN];
struct mtx {
  long long c[2][2];
};
long long add(long long a, long long b) { return (a + b + MOD) % MOD; }
long long mul(long long a, long long b) { return (a * b + MOD) % MOD; }
mtx operator*(mtx a, mtx b) {
  mtx res;
  for (int i = 0; i < 2; i++) {
    for (int j = 0; j < 2; j++) {
      res.c[i][j] = 0;
      for (int k = 0; k < 2; k++) {
        res.c[i][j] = add(res.c[i][j], mul(a.c[i][k], b.c[k][j]));
      }
    }
  }
  return res;
}
mtx binpow(mtx a, long long st) {
  mtx ans;
  ans.c[0][1] = ans.c[1][0] = 0;
  ans.c[0][0] = ans.c[1][1] = 1;
  for (; st; st >>= 1) {
    if (st & 1) ans = ans * a;
    a = a * a;
  }
  return ans;
}
void solve() {
  long long n, x, y;
  cin >> n >> x >> y >> MOD;
  long long s = 0;
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
    s = add(s, a[i]);
  }
  if (n == 1) {
    cout << s;
    return;
  }
  mtx b;
  b.c[0][0] = 1;
  b.c[0][1] = 1;
  b.c[1][0] = 1;
  b.c[1][1] = 0;
  mtx b2 = binpow(b, x);
  if (0) cout << b2.c[0][0] << " " << b2.c[0][1] << endl;
  if (0) cout << b2.c[1][0] << " " << b2.c[1][1] << endl;
  long long fs = a[0];
  long long sc = add(mul(a[n - 1], b2.c[0][0]), mul(a[n - 2], b2.c[0][1]));
  if (0) cout << "FIRST " << fs << " LAST " << sc << endl;
  b.c[0][0] = 3 % MOD;
  b.c[0][1] = add(MOD - a[0], MOD - a[n - 1]);
  b.c[1][0] = 0;
  b.c[1][1] = 1;
  b2 = binpow(b, x);
  long long s2 = add(mul(b2.c[0][0], s), b2.c[0][1]);
  if (0) cout << s2 << endl;
  b.c[0][0] = 3 % MOD;
  b.c[0][1] = add(add(MOD, -fs), add(MOD, -sc));
  b.c[1][0] = 0;
  b.c[1][1] = 1;
  b2 = binpow(b, y);
  if (0) cout << b2.c[0][0] << " " << b2.c[0][1] << endl;
  if (0) cout << b2.c[1][0] << " " << b2.c[1][1] << endl;
  long long s3 = add(mul(s2, b2.c[0][0]), b2.c[0][1]);
  cout << s3;
}
int main() {
  int t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
