#include <bits/stdc++.h>
using namespace std;
long long k, x, y, s;
int n, P, Maxi, Mini, a[1000010];
long long g[2][2], c[2][2], t[2][2];
void multA() {
  t[0][0] = (long long)g[0][0] * c[0][0] % P + (long long)g[0][1] * c[1][0] % P;
  t[0][0] %= P;
  t[0][1] = (long long)g[0][0] * c[0][1] % P + (long long)g[0][1] * c[1][1] % P;
  t[0][1] %= P;
  t[1][0] = (long long)g[1][0] * c[0][0] % P + (long long)g[1][1] * c[1][0] % P;
  t[1][0] %= P;
  t[1][1] = (long long)g[1][0] * c[0][1] % P + (long long)g[1][1] * c[1][1] % P;
  t[1][1] %= P;
  memcpy(g, t, sizeof(g));
}
void multB() {
  t[0][0] = (long long)c[0][0] * c[0][0] % P + (long long)c[0][1] * c[1][0] % P;
  t[0][0] %= P;
  t[0][1] = (long long)c[0][0] * c[0][1] % P + (long long)c[0][1] * c[1][1] % P;
  t[0][1] %= P;
  t[1][0] = (long long)c[1][0] * c[0][0] % P + (long long)c[1][1] * c[1][0] % P;
  t[1][0] %= P;
  t[1][1] = (long long)c[1][0] * c[0][1] % P + (long long)c[1][1] * c[1][1] % P;
  t[1][1] %= P;
  memcpy(c, t, sizeof(c));
}
void pow(long long m) {
  g[0][0] = g[1][1] = 1;
  g[0][1] = g[1][0] = 0;
  for (; m; m >>= 1) {
    if (m & 1) multA();
    multB();
  }
}
int main() {
  cin >> n >> x >> y >> P;
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]), s += (long long)a[i];
  Mini = a[1];
  Maxi = a[n];
  k = Maxi + Mini;
  s %= P;
  c[0][0] = 3;
  c[0][1] = 0;
  c[1][0] = c[1][1] = 1;
  pow(x);
  s = (long long)s * g[0][0] % P - (long long)k * g[1][0] % P;
  s = (s + P) % P;
  c[0][0] = 0;
  c[0][1] = c[1][0] = c[1][1] = 1;
  pow(x);
  Maxi = (long long)a[n - 1] * g[0][1] % P + (long long)a[n] * g[1][1] % P;
  k = Maxi + Mini;
  c[0][0] = 3;
  c[0][1] = 0;
  c[1][0] = c[1][1] = 1;
  pow(y);
  s = (long long)s * g[0][0] % P - (long long)k * g[1][0] % P;
  s = (s + P) % P;
  cout << s << endl;
  return 0;
}
