#include <bits/stdc++.h>
using namespace std;
const int MXSZ = 1e5 + 5;
const long long mod = 998244353;
const long long m0d = 998244352;
struct Matrix {
  long long m[103][103];
  Matrix() { memset(m, 0, sizeof(m)); }
  Matrix operator*(Matrix const &rhs) {
    Matrix ret;
    for (int i = 1; i <= 100; i++) {
      for (int j = 1; j <= 100; j++) {
        ret.m[i][j] = 0;
        for (int il = 1; il <= 100; il++) {
          ret.m[i][j] += ((m[i][il] * rhs.m[il][j]) % m0d);
          ret.m[i][j] %= m0d;
        }
      }
    }
    return ret;
  }
  void print(int n) {
    for (int i = 1; i <= n; i++)
      for (int j = 1; j <= n; j++) cout << m[i][j] << " \n"[j == n];
    cout << "================\n";
  }
};
long long n, m, k;
long long b[MXSZ];
Matrix base, ans;
void fpow(Matrix b, long long e) {
  Matrix &ret = ans;
  for (int i = 1; i <= k; i++) ret.m[i][i] = 1;
  while (e > 0) {
    if (e & 1) {
      ret = ret * b;
    }
    b = b * b;
    e >>= 1;
  }
}
long long fpow2(long long b, long long e) {
  long long ret = 1;
  while (e > 0) {
    if (e & 1) {
      (ret *= b) %= mod;
    }
    b *= b;
    b %= mod;
    e >>= 1;
  }
  return ret;
}
long long g = 3LL, primroot = 1;
map<long long, long long> mp;
long long BSGS() {
  long long l = 1, r = mod, sq = 1;
  while (l <= r) {
    long long md = (l + r) >> 1;
    if (md * md > mod) {
      r = md - 1;
    } else {
      l = md + 1;
      sq = md;
    }
  }
  for (int i = 1; i <= sq; i++) {
    mp[fpow2(primroot, i * sq)] = i;
  }
  for (int i = 0; i <= sq; i++) {
    long long cur = fpow2(primroot, i) * m;
    cur %= mod;
    if (mp.count(cur)) {
      long long ans = mp[cur] * sq - i;
      if (ans < mod) return ans;
    }
  }
  return -1;
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> k;
  for (int i = 1; i <= k; i++) {
    cin >> b[i];
  }
  cin >> n >> m;
  for (int i = 1; i <= k; i++) {
    base.m[1][i] = b[i];
  }
  for (int i = 2; i <= k; i++) {
    base.m[i][i - 1] = 1;
  }
  fpow(base, n - k);
  long long x = ans.m[1][1];
  primroot = fpow2(g, x);
  long long POWER = BSGS();
  if (POWER == -1) {
    cout << -1 << '\n';
    return 0;
  }
  cout << fpow2(g, POWER) << '\n';
  return 0;
}
