#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1.0);
const double eps = 1e-10;
const int INF = 0x3f3f3f3f;
const int maxn = 105;
int mod = 998244353;
int g = 3, k, n, m;
map<int, int> ma;
int b[maxn];
struct matrix {
  int c[maxn][maxn];
  int n;
  matrix() {
    this->n = k;
    for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= n; j++) {
        c[i][j] = 0;
      }
    }
  }
  matrix operator*(const matrix &m) const {
    matrix res;
    for (int i = 1; i <= n; i++) {
      for (int k = 1; k <= n; k++) {
        for (int j = 1; j <= n; j++) {
          res.c[i][j] += 1ll * c[i][k] * m.c[k][j] % mod;
          res.c[i][j] %= mod;
        }
      }
    }
    return res;
  }
};
matrix qpow(matrix a, long long p) {
  matrix res;
  for (int i = 1; i <= k; i++) res.c[i][i] = 1;
  while (p) {
    if (p & 1) res = res * a;
    a = a * a;
    p >>= 1;
  }
  return res;
}
long long qpow(long long a, long long p, long long mod) {
  long long res = 1;
  while (p) {
    if (p & 1) res = res * a % mod;
    a = a * a % mod;
    p >>= 1;
  }
  return res;
}
int bsgs(int y, int z, int p) {
  ma.clear();
  int ans = -1, m = (int)ceil(sqrt(p)), s = z;
  for (int i = 0; i < m; i++) {
    ma[s] = i;
    s = 1ll * s * y % p;
  }
  int buf = qpow(y, m, p);
  s = 1;
  for (int i = 1; i <= m; i++) {
    s = 1ll * s * buf % p;
    if (ma.count(s)) {
      ans = i * m - ma[s];
      break;
    }
  }
  return ans;
}
void exgcd(long long a, long long b, long long &d, long long &x, long long &y) {
  if (b == 0) {
    d = a;
    x = 1;
    y = 0;
    return;
  }
  exgcd(b, a % b, d, y, x);
  y -= (a / b) * x;
}
int main(void) {
  scanf("%d", &k);
  for (int i = 1; i <= k; i++) {
    scanf("%d", &b[i]);
  }
  scanf("%d%d", &n, &m);
  int hn = bsgs(g, m, mod);
  matrix mat;
  for (int i = 1; i <= k; i++) {
    mat.c[1][i] = b[i];
  }
  for (int i = 2; i <= k; i++) {
    mat.c[i][i - 1] = 1;
  }
  --mod;
  matrix res = qpow(mat, n - k);
  int val = res.c[1][1];
  long long d, x, y;
  exgcd(val, mod, d, x, y);
  if (hn % d != 0) {
    puts("-1");
    return 0;
  }
  long long hk = 1ll * x * (hn / d) % (mod / d);
  hk = (hk % (mod / d) + (mod / d)) % (mod / d);
  ++mod;
  int fk = qpow(g, hk, mod);
  printf("%d\n", fk);
  return 0;
}
