#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 5;
const int inf = 1e9 + 1;
const double eps = 1e-15;
const int pw = 257;
int n;
long long x, y, mod, a[N], ans;
inline long long md(long long x) {
  x %= mod;
  x += mod;
  x %= mod;
  return x;
}
struct Matrix {
  long long val[5][5], t[5][5];
  inline void operator*=(Matrix x) {
    memset(t, 0, sizeof(t));
    for (int i = 0; i <= 1; ++i)
      for (int j = 0; j <= 1; ++j)
        for (int k = 0; k <= 1; ++k)
          t[i][j] = md(md(val[i][k] * x.val[k][j]) + t[i][j]);
    for (int i = 0; i <= 1; ++i)
      for (int j = 0; j <= 1; ++j) val[i][j] = t[i][j];
  }
} res, p;
inline long long calc_p(long long m) {
  res.val[0][0] = 0, res.val[0][1] = 1;
  res.val[1][0] = 0, res.val[1][1] = 0;
  p.val[0][0] = 3, p.val[0][1] = 0;
  p.val[1][0] = 1, p.val[1][1] = 1;
  while (m) {
    if (m % 2 == 1) res *= p;
    p *= p;
    m /= 2;
  }
  return res.val[0][0];
}
inline long long calc_mx(long long m) {
  res.val[0][0] = 0, res.val[0][1] = 1;
  res.val[1][0] = 0, res.val[1][1] = 0;
  p.val[0][0] = 0, p.val[0][1] = 1;
  p.val[1][0] = 1, p.val[1][1] = 1;
  while (m) {
    if (m % 2 == 1) res *= p;
    p *= p;
    m /= 2;
  }
  return md(md(res.val[0][0] * a[n - 1]) + md(res.val[0][1] * a[n]));
}
int main() {
  ios_base ::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n >> x >> y >> mod;
  for (int i = 1; i <= n; ++i) {
    cin >> a[i];
    a[i] = md(a[i]);
  }
  if (n == 1) return cout << a[1], 0;
  long long pxpy = calc_p(x + y);
  long long py = calc_p(y);
  long long mx = calc_mx(x);
  for (int i = 1; i <= n; ++i) {
    ans = md(md(md(pxpy + 1) * a[i]) + ans);
    if (i != 1 && i != n) ans = md(md(pxpy * a[i]) + ans);
  }
  ans = md(ans - md(md(mx - a[n]) * py));
  cout << ans;
  return 0;
}
