#include <bits/stdc++.h>
using namespace std;
const int N = (int)1e6;
long long a[N], n, x, y, p, sum;
struct mat {
  long long a[2][2];
  mat() { memset(a, 0, sizeof a); }
  mat(long long x, long long b, long long c, long long d) {
    a[0][0] = x;
    a[0][1] = b;
    a[1][0] = c;
    a[1][1] = d;
  }
};
mat operator*(mat a, mat b) {
  mat c = mat();
  for (int i = 0; i < (int)2; ++i)
    for (int j = 0; j < (int)2; ++j)
      for (int k = 0; k < (int)2; ++k)
        c.a[i][j] = (c.a[i][j] + a.a[i][k] * b.a[k][j]) % p;
  return c;
}
mat deg(mat a, long long n) {
  if (n == 0) return mat(1, 0, 0, 1);
  mat x = deg(a, n / 2);
  x = x * x;
  if (n % 2 == 1) x = x * a;
  return x;
}
long long phib(long long a, long long b, long long n) {
  mat x = deg(mat(0, 1, 1, 1), n);
  return (x.a[0][0] * b + x.a[0][1] * a) % p;
}
long long deg(long long a, long long n) {
  return deg(mat(a, 0, 0, 0), n).a[0][0];
}
long long sdeg(long long s, long long b, long long d) {
  mat a = deg(mat(1, 0, ((-b % p) + p) % p, 3), d);
  return (s * a.a[1][1] + a.a[1][0]) % p;
}
int main() {
  scanf("%I64d%I64d%I64d%I64d", &n, &x, &y, &p);
  for (int i = 0; i < (int)n; ++i) scanf("%I64d", &a[i]);
  reverse(a, a + n);
  long long mn = a[n - 1], mx = 0;
  if (n == 1) {
    cout << a[0] % p;
    return 0;
  };
  mx = phib(a[0], a[1], x + 1);
  for (int i = 0; i < (int)n; ++i) sum = (sum + a[i]) % p;
  sum = sdeg(sum, a[0] + a[n - 1], x);
  sum = sdeg(sum, mn + mx, y);
  cout << sum;
}
