#include <bits/stdc++.h>
static const long long LLMAX = 0x7fffffffffffffffLL;
static const int IMAX = 0x7fffffff;
using namespace std;
long long n, x, y, p;
long long a[static_cast<int>(1e6 + 1024)];
template <class T>
struct Matrix {
  T data[2][2];
  Matrix& operator=(const Matrix& rhs) {
    for (int i = 0; i < 2; ++i) {
      for (int j = 0; j < 2; ++j) {
        this->data[i][j] = rhs.data[i][j];
      }
    }
    return *this;
  }
  Matrix& operator*=(const Matrix& rhs) {
    Matrix temp;
    for (int i = 0; i < 2; ++i) {
      for (int j = 0; j < 2; ++j) {
        temp.data[i][j] = 0;
        for (int k = 0; k < 2; ++k) {
          temp.data[i][j] += (this->data[i][k] * rhs.data[k][j]) % p;
        }
        temp.data[i][j] %= p;
      }
    }
    *this = temp;
    return *this;
  }
  Matrix& operator%=(const T& rhs) {
    for (int i = 0; i < 2; ++i) {
      for (int j = 0; j < 2; ++j) {
        this->data[i][j] %= rhs;
      }
    }
    return *this;
  }
  const Matrix operator%(const T& other) const {
    Matrix result = *this;
    result %= other;
    return result;
  }
  const Matrix operator*(const Matrix& rhs) const {
    Matrix result = *this;
    result *= rhs;
    return result;
  }
};
template <class T>
Matrix<T> quickpow(T n) {
  Matrix<T> p;
  p.data[0][0] = 1;
  p.data[0][1] = 1;
  p.data[1][0] = 1;
  p.data[1][1] = 0;
  Matrix<T> I;
  I.data[0][0] = 1;
  I.data[0][1] = 0;
  I.data[1][1] = 1;
  I.data[1][0] = 0;
  Matrix<T> r = I;
  while (n) {
    if (n & 1) r *= p;
    n >>= 1;
    p *= p;
  }
  return r;
}
template <class T>
T modqpow(T a, T n, T m) {
  T x = a;
  T y = (n & 1) ? a : 1;
  T np = (n >> 1);
  while (np > 0) {
    x = x * x % m;
    if (np & 1) y = y == 1 ? x : y * x % m;
    np = (np >> 1);
  }
  return y;
}
long long nextMax() {
  if (n == 1LL) {
    return a[0];
  }
  Matrix<long long> m = quickpow(x);
  return (m.data[1][0] * a[n - 2] % p + m.data[0][0] * a[n - 1] % p) % p;
}
long long getAns(long long sum, long long minv, long long maxv,
                 long long times) {
  long long m = (minv % p + maxv % p) % p;
  long long ans = modqpow(3LL, times, p) % p;
  long long toMinus = (((ans - 1LL) % (p)) / 2LL) * m % p;
  ans = (((ans * sum % p) % p - toMinus) % p + p) % p;
  return ans;
}
long long mod(long long v) {
  while (v > p) {
    v -= p;
  }
  return v;
}
int main() {
  while (~scanf("%I64d%I64d%I64d%I64d", &n, &x, &y, &p)) {
    p *= 2LL;
    long long ans = 0LL;
    for (long long i = 0; i < n; ++i) {
      scanf("%I64d", &a[i]);
      ans += a[i];
    }
    ans %= p;
    ans = getAns(ans, a[0], a[n - 1], x);
    long long next = nextMax();
    ans = getAns(ans, a[0], next, y);
    p /= 2LL;
    printf("%I64d\n", (ans % p + p) % p);
  }
  return 0;
}
