#include <bits/stdc++.h>
using namespace std;
template <class T>
inline void read(T &x) {
  x = 0;
  char c = getchar();
  int f = 1;
  while (!isdigit(c)) {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (isdigit(c)) x = x * 10 - '0' + c, c = getchar();
  x *= f;
}
const int mod = 998244353;
int Pow(int x, int y, int mod) {
  int res = 1;
  while (y) {
    if (y & 1) res = res * (long long)x % mod;
    x = x * (long long)x % mod, y >>= 1;
  }
  return res;
}
map<int, int> mp;
int cal(int x, int b) {
  if (b == 1) return 0;
  int M = ceil(sqrt(mod)), t = b;
  mp[t] = 0;
  for (int i = 1; i <= M; ++i) t = t * (long long)x % mod, mp[t] = i;
  t = Pow(x, M, mod);
  int q = t;
  for (int i = 1; i <= M; ++i) {
    if (mp.count(q)) return i * M - mp[q];
    q = q * (long long)t % mod;
  }
  return -1;
}
int len;
struct Mat {
  int a[110][110];
  Mat() { memset(a, 0, sizeof(a)); }
  void E() {
    for (int i = 1; i <= len; ++i)
      for (int j = 1; j <= len; ++j) a[i][j] = i == j;
  }
} D;
Mat Mul(Mat A, Mat B) {
  Mat C;
  for (int i = 1; i <= len; ++i)
    for (int k = 1; k <= len; ++k)
      if (A.a[i][k]) {
        for (int j = 1; j <= len; ++j)
          C.a[i][j] =
              (C.a[i][j] + A.a[i][k] * (long long)B.a[k][j]) % (mod - 1);
      }
  return C;
}
Mat mpow(Mat x, int y) {
  Mat res;
  res.E();
  while (y) {
    if (y & 1) res = Mul(res, x);
    x = Mul(x, x), y >>= 1;
  }
  return res;
}
int exgcd(int &x, int &y, int a, int b) {
  if (!b) {
    x = 1, y = 0;
    return a;
  }
  int g = exgcd(y, x, b, a % b);
  y -= a / b * x;
  return g;
}
int b[110];
int main() {
  int m, n, X;
  read(m);
  for (int i = 1; i <= m; ++i) read(b[i]);
  read(n), read(X);
  for (int i = 2; i <= m; ++i) D.a[i][i - 1] = 1;
  for (int i = 1; i <= m; ++i) D.a[i][m] = b[m - i + 1];
  len = m;
  D = mpow(D, n - m);
  int xi = D.a[m][m], y = cal(3, X);
  int x1, y1, g = exgcd(x1, y1, xi, mod - 1);
  if (y % g) {
    puts("-1");
    return 0;
  }
  x1 = x1 % (mod - 1) * (long long)(y / g % (mod - 1)) % (mod - 1);
  x1 = (x1 + mod - 1) % (mod - 1);
  int ans = Pow(3, x1, mod);
  cout << ans << endl;
  return 0;
}
