#include <bits/stdc++.h>
using namespace std;
const int N = 1000010;
int mod, n;
long long x, y;
int arr[N];
int fres = 1;
int fff[N];
vector<vector<int> > mat;
vector<vector<int> > mul(vector<vector<int> > &a, vector<vector<int> > &b) {
  vector<vector<int> > res((int)a.size(), vector<int>((int)a.size(), 0));
  for (int i = 0; i < (int)a.size(); i++) {
    for (int j = 0; j < (int)a.size(); j++) {
      for (int k = 0; k < (int)a.size(); k++) {
        res[i][j] += (long long)a[i][k] * b[k][j] % mod;
        res[i][j] %= mod;
      }
    }
  }
  return res;
}
vector<vector<int> > matpower(vector<vector<int> > &mat, long long po) {
  if (po == 1) return mat;
  vector<vector<int> > res = matpower(mat, po / 2);
  res = mul(res, res);
  if (po & 1) res = mul(res, mat);
  return res;
}
int fastpower(int num, long long po) {
  fres = 1;
  num %= mod;
  while (po > 0) {
    if (po & 1) fres = (long long)fres * num % mod;
    po >>= 1;
    num = (long long)num * num % mod;
  }
  return fres;
}
int getsum(int tmp, long long po) {
  if (po == 0) {
    return 0;
  }
  int cur = getsum(tmp, po / 2);
  int cur2 = (long long)fastpower(tmp, po / 2) * cur % mod;
  cur += cur2;
  cur %= mod;
  if (po & 1) {
    cur += fastpower(tmp, po);
    cur %= mod;
  }
  return cur;
}
int get(int sum, long long x, int k) {
  sum %= mod;
  k %= mod;
  if (x == 0) return sum;
  int res = fastpower(3, x);
  res = (long long)res * sum % mod;
  int res2 = (getsum(3, x - 1) + 1) % mod;
  res2 = (long long)res2 * k % mod;
  res -= res2;
  res %= mod;
  res += mod;
  res %= mod;
  return res;
}
int main() {
  int sum = 0;
  cin >> n >> x >> y >> mod;
  fff[0] = 0;
  fff[1] = 1;
  for (int i = 2; i < N; i++) fff[i] = (fff[i - 1] + fff[i - 2]) % mod;
  for (int i = 0; i < n; i++) {
    scanf("%d", &arr[i]);
    arr[i] %= mod;
    sum += arr[i];
    sum %= mod;
  }
  if (n == 1) {
    cout << arr[0] << endl;
    return 0;
  }
  int res = get(sum, x, (arr[0] + arr[n - 1]) % mod);
  mat.resize(2, vector<int>(2, 1));
  mat[1][1] = 0;
  vector<vector<int> > fib = matpower(mat, x + 1);
  int best = (long long)arr[n - 1] * fib[0][1] % mod;
  best += (long long)fib[1][1] * arr[n - 2] % mod;
  best %= mod;
  res = get(res, y, (arr[0] + best) % mod);
  cout << res << endl;
  return 0;
}
