#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:100000000000000")
using namespace std;
const long long int INF = 2e9;
long long int mod;
void create_new(vector<vector<long long int> > &with, long long int n,
                long long int m) {
  with.resize(n, vector<long long int>(m, 0));
}
vector<vector<long long int> > mult(vector<vector<long long int> > &f,
                                    vector<vector<long long int> > &s) {
  vector<vector<long long int> > res;
  create_new(res, (long long int)(f).size(), (long long int)(s[0]).size());
  for (long long int i = 0; i < ((long long int)(res).size()); i++) {
    for (long long int j = 0; j < ((long long int)(res[i]).size()); j++) {
      for (long long int k = 0; k < ((long long int)(s).size()); k++) {
        res[i][j] = (res[i][j] + (f[i][k] * s[k][j]) % mod) % mod;
      }
    }
  }
  return res;
}
vector<vector<long long int> > binpow(vector<vector<long long int> > &f,
                                      long long int st) {
  if (st == 1) {
    return f;
  }
  if (st & 1) {
    vector<vector<long long int> > with = binpow(f, st - 1);
    return mult(with, f);
  }
  vector<vector<long long int> > with = binpow(f, st / 2);
  return mult(with, with);
}
void init_main(vector<vector<long long int> > &mine) {
  mine.clear();
  create_new(mine, 2, 2);
  mine[0][0] = mine[0][1] = 1 % mod;
  mine[1][1] = 3 % mod;
}
void init_fib(vector<vector<long long int> > &mine) {
  mine.clear();
  create_new(mine, 2, 2);
  mine[0][1] = mine[1][0] = mine[1][1] = 1 % mod;
}
int main() {
  long long int n, x, y;
  cin >> n >> x >> y >> mod;
  vector<long long int> op(n);
  vector<vector<long long int> > f, s, detf, dets;
  create_new(f, 1, 2);
  create_new(s, 1, 2);
  init_main(detf);
  init_fib(dets);
  for (long long int i = 0; i < (n); i++) {
    cin >> op[i];
    if (i && i < n - 1) {
      f[0][1] = (f[0][1] + op[i]) % mod;
    } else
      f[0][0] = (f[0][0] + op[i]) % mod;
  }
  if (n == 1) {
    cout << op[0] % mod;
    return 0;
  }
  s[0][0] = op[n - 2] % mod;
  s[0][1] = op[n - 1] % mod;
  if (x) {
    detf = binpow(detf, x);
    dets = binpow(dets, x);
    f = mult(f, detf);
    s = mult(s, dets);
    f[0][0] = (f[0][0] - op[n - 1] % mod + mod) % mod;
    f[0][0] = (f[0][0] + s[0][1] % mod) % mod;
    f[0][1] = (f[0][1] + op[n - 1] % mod) % mod;
    f[0][1] = (f[0][1] - s[0][1] % mod + mod) % mod;
  }
  init_main(detf);
  if (y) {
    detf = binpow(detf, y);
    f = mult(f, detf);
  }
  cout << (f[0][0] + f[0][1]) % mod;
}
