#include <bits/stdc++.h>
using namespace std;
void print(vector<int> v) {
  printf("[");
  for (int i = 0; i < ((int)(v.size())); ++i) {
    if (i) printf(",");
    printf("%d", v[i]);
  }
  printf("]");
}
void print(vector<vector<int> > v) {
  for (int i = 0; i < ((int)(v.size())); ++i) {
    print(v[i]);
    printf(" ");
  }
  printf("\n");
}
vector<int> concat(vector<int> v1, vector<int> v2) {
  vector<int> r = v1;
  for (int i = 0; i < ((int)(v2.size())); ++i) {
    r.push_back(v2[i]);
  }
  return r;
}
vector<int> getMax(vector<vector<int> > v) {
  int mx = 0;
  vector<int> r;
  for (int i = 0; i < ((int)(v.size())); ++i) {
    if (((int)(v[i].size())) >= mx) {
      mx = ((int)(v[i].size()));
      r = v[i];
    }
  }
  return r;
}
int getCount(vector<int> v, int x) {
  int r = 0;
  for (int i = 0; i < ((int)(v.size())); ++i) {
    if (v[i] == x) ++r;
  }
  return r;
}
int getCount(vector<vector<int> > v, int x) {
  int r = 0;
  for (int i = 0; i < ((int)(v.size())); ++i) {
    r += getCount(v[i], x);
  }
  return r;
}
long long powMod(long long a, long long n, long long p) {
  long long r = 1;
  while (n) {
    if (n & 1) {
      r *= a;
      r %= p;
    }
    a *= a;
    a %= p;
    n >>= 1;
  }
  return r;
}
typedef long long Matrix[2][2];
void mulMatrix(Matrix a, Matrix b, long long p) {
  Matrix c;
  memset(c, 0, sizeof(c));
  for (int i = 0; i < 2; ++i)
    for (int j = 0; j < 2; ++j)
      for (int k = 0; k < 2; ++k) {
        c[i][j] += a[i][k] * b[k][j];
        c[i][j] %= p;
      }
  for (int i = 0; i < 2; ++i)
    for (int j = 0; j < 2; ++j) a[i][j] = c[i][j];
}
long long getFib(long long n, long long p) {
  if (n < 0) return 0;
  if (n < 2) return 1;
  Matrix r = {{1, 0}, {0, 1}};
  Matrix a = {{1, 1}, {1, 0}};
  --n;
  while (n) {
    if (n & 1) mulMatrix(r, a, p);
    mulMatrix(a, a, p);
    n >>= 1;
  }
  long long val = (r[0][0] + r[0][1]) % p;
  return val;
  long long f1 = 1, f2 = 1;
  for (int i = 2; i <= n; ++i) {
    long long f = f1 + f2;
    f %= p;
    f1 = f2;
    f2 = f;
  }
  return f2;
}
long long sumPow3(long long n, long long p) {
  if (n == 0) return 0;
  if (n == 1) return 1;
  if (n & 1) {
    long long t = sumPow3(n - 1, p);
    return (t * 3 + 1) % p;
  } else {
    long long t = sumPow3(n >> 1, p);
    return (t + t * powMod(3, n >> 1, p)) % p;
  }
}
long long get(long long n, long long p) {
  long long t = sumPow3(n, p);
  t = (t + 1) % p;
  return t;
}
int A[1 << 20];
void solve() {
  long long n, x, y, p;
  cin >> n >> x >> y >> p;
  long long x3 = powMod(3, x, p);
  long long x31 = get(x, p);
  long long s = 0;
  for (int i = 0; i < n; ++i) {
    scanf("%d", A + i);
    if (i == 0 || i == n - 1)
      s += A[i] * x31;
    else
      s += A[i] * x3;
    s %= p;
  }
  if (n == 1) {
    cout << A[0] % p << endl;
    exit(0);
  }
  long long f1 = getFib(x - 1, p);
  long long f2 = getFib(x, p);
  long long t = f1 * A[n - 2] % p + f2 * A[n - 1] % p;
  t %= p;
  long long y3 = powMod(3, y, p);
  long long y31 = get(y, p);
  long long ans = (s - A[0] - t) % p;
  if (ans < 0) ans += p;
  ans = ans * y3 % p;
  ans += (A[0] + t) * y31 % p;
  ans %= p;
  cout << ans << endl;
  exit(0);
}
int main() {
  solve();
  vector<vector<int> > v;
  int n = 6;
  for (int i = 0; i < n; ++i) {
    v.push_back(vector<int>(1, i));
  }
  int c = 9;
  for (int i = 0; i < c; ++i) {
    vector<vector<int> > t;
    for (int j = 0; j < ((int)(v.size())); ++j) {
      if (j) t.push_back(concat(v[j - 1], v[j]));
      t.push_back(v[j]);
    }
    v = t;
    vector<int> u = getMax(v);
    for (int j = 0; j < n; ++j) {
      printf("%d ", getCount(v, j));
    }
    printf("\n");
  }
  return 0;
}
