#include <bits/stdc++.h>
using namespace std;
int n, m, l, i, j, k, p, s;
int a[1000001];
long long x, y;
int getPow(long long n) {
  if (n == 0) return 1;
  if (n % 2 == 1) return getPow(n - 1) * 3LL % p;
  int t = getPow(n / 2);
  return (long long)t * (long long)t % p;
}
int getSum(long long n) {
  if (n == 0) return 0;
  if (n % 2 == 1) return (getSum(n - 1) + getPow(n - 1)) % p;
  int t = getSum(n / 2);
  return (long long)t * ((long long)getPow(n / 2) + 1) % p;
}
int op(int s, int t, long long n) {
  if (n == 0) return s;
  long long a = (long long)getPow(n) * (long long)s;
  a -= (long long)getSum(n) * (long long)t;
  a %= p;
  if (a < 0) a += p;
  return a;
}
int main() {
  cin >> n >> x >> y >> p;
  for (i = 0; i < n; i++) {
    scanf("%d", &a[i]);
    s = (s + a[i]) % p;
  }
  if (n > 1) {
    s = op(s, a[0] + a[n - 1], x);
    long long A[2][2], C[2][2], R[2][2];
    for (i = 0; i < 2; i++)
      for (j = 0; j < 2; j++) A[i][j] = (i == j);
    R[1][0] = R[1][1] = R[0][1] = 1;
    R[0][0] = 0;
    x++;
    while (x > 0) {
      if (x & 1) {
        for (i = 0; i < 2; i++)
          for (j = 0; j < 2; j++) C[i][j] = 0;
        for (k = 0; k < 2; k++)
          for (i = 0; i < 2; i++)
            for (j = 0; j < 2; j++) C[i][j] = (C[i][j] + A[i][k] * R[k][j]) % p;
        for (i = 0; i < 2; i++)
          for (j = 0; j < 2; j++) A[i][j] = C[i][j];
      }
      x /= 2;
      for (i = 0; i < 2; i++)
        for (j = 0; j < 2; j++) C[i][j] = 0;
      for (k = 0; k < 2; k++)
        for (i = 0; i < 2; i++)
          for (j = 0; j < 2; j++) C[i][j] = (C[i][j] + R[i][k] * R[k][j]) % p;
      for (i = 0; i < 2; i++)
        for (j = 0; j < 2; j++) R[i][j] = C[i][j];
    }
    long long t = A[0][0] * a[n - 2] + A[0][1] * a[n - 1] + a[0];
    t = t % p;
    s = op(s, (int)t, y);
  }
  cout << s << endl;
  return 0;
}
