#include <bits/stdc++.h>
using namespace std;
int n;
long long x, y;
long long p;
int a[1010010];
struct Matrix {
  long long a[2][2];
  Matrix& operator=(const Matrix& m) {
    for (int i = 0; i < 2; ++i)
      for (int j = 0; j < 2; ++j) a[i][j] = m.a[i][j];
    return *this;
  }
  Matrix operator*(const Matrix& m) const {
    Matrix ret;
    for (int i = 0; i < 2; ++i) {
      for (int j = 0; j < 2; ++j) {
        ret.a[i][j] = 0;
        for (int k = 0; k < 2; ++k) {
          ret.a[i][j] = (ret.a[i][j] + a[i][k] * m.a[k][j]) % p;
        }
      }
    }
    return ret;
  }
  Matrix pow(long long k) {
    Matrix ret;
    ret.e();
    Matrix cur = *this;
    while (k > 0) {
      if (k & 1) ret = ret * cur;
      cur = cur * cur;
      k /= 2;
    }
    return ret;
  }
  Matrix() { memset(a, 0, sizeof(a)); }
  void e() {
    for (int i = 0; i < 2; ++i)
      for (int j = 0; j < 2; ++j) a[i][j] = (i == j);
  }
};
int main() {
  cin >> n >> x >> y >> p;
  for (int i = 0; i < n; ++i) {
    scanf("%d", &a[i]);
    a[i] %= p;
  }
  if (n == 1) {
    cout << a[0];
    return 0;
  }
  Matrix A;
  A.a[0][0] = 0;
  A.a[0][1] = 1;
  A.a[1][0] = 1;
  A.a[1][1] = 1;
  A = A.pow(x);
  long long maxa = (A.a[1][0] * a[n - 2] + A.a[1][1] * a[n - 1]) % p;
  long long s = 0, s2 = (a[0] + a[n - 1]) % p;
  for (int i = 0; i < n; ++i) {
    s += a[i];
    s %= p;
  }
  Matrix B;
  B.a[0][0] = 3 % p;
  B.a[0][1] = p - 1;
  B.a[1][0] = 0;
  B.a[1][1] = 1;
  Matrix C = B.pow(x);
  s = (C.a[0][0] * s + C.a[0][1] * s2) % p;
  s2 = (a[0] + maxa) % p;
  C = B.pow(y);
  s = (C.a[0][0] * s + C.a[0][1] * s2) % p;
  cout << s;
  return 0;
}
