#include <bits/stdc++.h>
using namespace std;
long long x, y, p, a[1000001];
int n;
vector<int> v;
vector<vector<int> > create(bool on) {
  vector<vector<int> > res;
  for (int i = 0; i < 5; i++) {
    vector<int> t;
    for (int j = 0; j < 5; j++) {
      t.push_back(0);
    }
    res.push_back(t);
  }
  if (on) {
    for (int i = 0; i < 5; i++) {
      res[i][i] = 1;
    }
  }
  return res;
}
vector<vector<int> > mult(vector<vector<int> > a, vector<vector<int> > b) {
  vector<vector<int> > res = create(0);
  for (int i = 0; i < 5; i++) {
    for (int j = 0; j < 5; j++) {
      for (int t = 0; t < 5; t++) {
        res[i][j] += ((a[i][t] * 1ll * b[t][j]) % p);
        res[i][j] %= p;
      }
    }
  }
  return res;
}
vector<vector<int> > binpow(vector<vector<int> > a, long long b) {
  if (b == 0) {
    vector<vector<int> > res = create(1);
    return res;
  }
  if (b % 2 == 0) {
    vector<vector<int> > c = binpow(a, b / 2);
    return mult(c, c);
  } else {
    return mult(a, binpow(a, b - 1));
  }
}
int main() {
  ios_base ::sync_with_stdio(false);
  cin.tie(nullptr);
  cin >> n >> x >> y >> p;
  long long sum = 0;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    sum += a[i];
    sum %= p;
  }
  vector<vector<int> > g = create(0);
  g[0][0] = g[1][1] = 1;
  g[2][0] = g[2][1] = -1;
  g[2][2] = 3;
  g[3][4] = 1;
  g[4][3] = 1;
  g[4][4] = 1;
  v.push_back(a[1]);
  v.push_back(a[n]);
  v.push_back(sum);
  v.push_back(a[n - 1]);
  v.push_back(a[n]);
  g = binpow(g, x);
  vector<int> v2;
  for (int i = 0; i < 5; i++) {
    v2.push_back(0);
    for (int j = 0; j < 5; j++) {
      v2[i] += ((v[j] * 1ll * g[i][j]) % p);
      v2[i] %= p;
    }
  }
  g = create(0);
  g[0][0] = g[1][1] = 1;
  g[2][0] = g[2][1] = -1;
  g[2][2] = 3;
  g[3][4] = 1;
  g[4][3] = 1;
  g[4][4] = 1;
  v.clear();
  v.push_back(v2[0]);
  v.push_back(v2[4]);
  v.push_back(v2[2]);
  v.push_back(v2[3]);
  v.push_back(v2[4]);
  g = binpow(g, y);
  int ans = 0;
  for (int i = 0; i < 5; i++) {
    ans += ((v[i] * 1ll * g[2][i]) % p);
    ans %= p;
  }
  while (ans < 0) {
    ans += p;
  }
  cout << ans;
}
