#include <bits/stdc++.h>
template <typename T>
void MACRO_VAR_Scan(T& t) {
  std::cin >> t;
}
template <typename First, typename... Rest>
void MACRO_VAR_Scan(First& first, Rest&... rest) {
  std::cin >> first;
  MACRO_VAR_Scan(rest...);
}
template <typename T>
void MACRO_VEC_ROW_Init(int n, T& t) {
  t.resize(n);
}
template <typename First, typename... Rest>
void MACRO_VEC_ROW_Init(int n, First& first, Rest&... rest) {
  first.resize(n);
  MACRO_VEC_ROW_Init(n, rest...);
}
template <typename T>
void MACRO_VEC_ROW_Scan(int p, T& t) {
  std::cin >> t[p];
}
template <typename First, typename... Rest>
void MACRO_VEC_ROW_Scan(int p, First& first, Rest&... rest) {
  std::cin >> first[p];
  MACRO_VEC_ROW_Scan(p, rest...);
}
template <class T>
inline T CHMAX(T& a, const T b) {
  return a = (a < b) ? b : a;
}
template <class T>
inline T CHMIN(T& a, const T b) {
  return a = (a > b) ? b : a;
}
template <class T>
using V = std::vector<T>;
template <class T>
using VV = V<V<T>>;
template <typename S, typename T>
std::ostream& operator<<(std::ostream& os, std::pair<S, T> p) {
  os << "(" << p.first << ", " << p.second << ")";
  return os;
}
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using PAIR = std::pair<ll, ll>;
using PAIRLL = std::pair<ll, ll>;
constexpr ll INFINT = 1 << 30;
constexpr ll INFINT_LIM = (1LL << 31) - 1;
constexpr ll INFLL = 1LL << 60;
constexpr ll INFLL_LIM = (1LL << 62) - 1 + (1LL << 62);
constexpr double EPS = 1e-6;
constexpr ll MOD = 998244353;
constexpr ll MOD_ = MOD - 1;
constexpr double PI = 3.141592653589793238462643383279;
template <class T, size_t N>
void FILL(T (&a)[N], const T& val) {
  for (auto& x : a) x = val;
}
template <class ARY, size_t N, size_t M, class T>
void FILL(ARY (&a)[N][M], const T& val) {
  for (auto& b : a) FILL(b, val);
}
template <class T>
void FILL(std::vector<T>& a, const T& val) {
  for (auto& x : a) x = val;
}
template <class ARY, class T>
void FILL(std::vector<std::vector<ARY>>& a, const T& val) {
  for (auto& b : a) FILL(b, val);
}
template <class T>
class MatrixMOD {
 private:
  std::valarray<std::valarray<T>> mat;

 public:
  MatrixMOD(size_t m = 0, size_t n = 0, T init = 0) {
    if (n == 0) n = m;
    mat.resize(m);
    for (size_t i = 0; i < m; ++i) mat[i].resize(n, init);
  }
  MatrixMOD(std::valarray<std::valarray<T>> a) { mat = a; }
  MatrixMOD<T> init(size_t m = 0, size_t n = 0, T init = 0) {
    if (n == 0) n = m;
    mat.resize(m);
    for (size_t i = 0; i < m; ++i) mat[i].resize(n, init);
    return *this;
  }
  std::valarray<T>& operator[](size_t i) { return mat[i]; }
  const std::valarray<T>& operator[](size_t i) const { return mat[i]; }
  MatrixMOD<T>& operator=(const MatrixMOD<T>& r) {
    for (size_t i = 0; i < mat.size(); ++i) mat[i] = r[i];
    return *this;
  }
  MatrixMOD<T> operator+() const { return mat; }
  MatrixMOD<T> operator-() const {
    MatrixMOD<T> res(mat.size());
    for (size_t i = 0; i < mat.size(); ++i) res[i] = (MOD_ - mat[i]) %= MOD_;
    return res;
  }
  MatrixMOD<T>& operator+=(const MatrixMOD<T>& r) {
    for (size_t i = 0; i < mat.size(); ++i) (mat[i] += r[i]) %= MOD_;
    return *this;
  }
  MatrixMOD<T>& operator+=(const T& x) {
    for (size_t i = 0; i < mat.size(); ++i) (mat[i] += x) %= MOD_;
    return *this;
  }
  MatrixMOD<T>& operator-=(const MatrixMOD<T>& r) { return *this += MOD_ - r; }
  MatrixMOD<T>& operator-=(const T& x) { return *this += MOD_ - x; }
  MatrixMOD<T>& operator*=(const MatrixMOD<T>& r) {
    MatrixMOD<T> res(*this);
    for (size_t i = 0; i < mat.size(); ++i) {
      for (size_t j = 0; j < r[0].size(); ++j) {
        res[i][j] = 0;
        for (size_t k = 0; k < mat[0].size(); ++k) {
          (res[i][j] += mat[i][k] * r[k][j] % MOD_) %= MOD_;
        }
      }
    }
    return *this = res;
  }
  MatrixMOD<T>& operator*=(const T& x) {
    for (size_t i = 0; i < mat.size(); ++i) (mat[i] *= x) %= MOD_;
    return *this;
  }
  MatrixMOD<T>& operator%=(const T& mod) {
    for (size_t i = 0; i < mat.size(); ++i) mat[i] %= MOD_;
    return *this;
  }
  MatrixMOD<T>& operator^=(ll p) {
    MatrixMOD<T> res(*this);
    for (size_t i = 0; i < mat.size(); ++i) {
      for (size_t j = 0; j < mat[0].size(); ++j) {
        res[i][j] = i == j;
      }
    }
    while (p) {
      if (p & 1) (res *= (*this)) %= MOD_;
      ((*this) *= (*this)) %= MOD_;
      p >>= 1;
    }
    for (size_t i = 0; i < mat.size(); ++i) mat[i] = res[i];
    return *this;
  }
  MatrixMOD<T> operator+(const MatrixMOD& r) const {
    MatrixMOD<T> res(mat);
    return res += r;
  }
  MatrixMOD<T> operator-(const MatrixMOD& r) const {
    MatrixMOD<T> res(mat);
    return res -= r;
  }
  MatrixMOD<T> operator*(const MatrixMOD& r) const {
    MatrixMOD<T> res(mat);
    return res *= r;
  }
  MatrixMOD<T> operator*(const T& r) const {
    MatrixMOD<T> res(mat);
    return res *= r;
  }
  MatrixMOD<T> operator^(const ll& p) const {
    MatrixMOD<T> res(mat);
    return res ^= p;
  }
  MatrixMOD<T> t() const {
    MatrixMOD<T> res(mat[0].size(), mat.size(), 0);
    for (size_t i = 0; i < mat[0].size(); ++i) {
      for (size_t j = 0; j < mat.size(); ++j) {
        res[i][j] = mat[j][i];
      }
    }
    return res;
  }
  static MatrixMOD<T> getUnit(size_t n) {
    MatrixMOD<T> res(n, n, 0);
    for (size_t i = 0; i < n; ++i) res[i][i] = 1;
    return res;
  }
  void show() const {
    for (const auto& r : mat) {
      for (const auto& x : r) {
        std::cerr << x << "\t";
      }
      std::cerr << std::endl;
    }
  }
};
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll modinv(ll a, ll b = MOD_, ll x = 1, ll y = 0) {
  if (b == 0) return x < 0 ? x + MOD_ : x;
  return modinv(b, a - a / b * b, y, x - a / b * y);
}
ll powMod(ll n, ll p, ll mod) {
  ll res = 1;
  while (p) {
    if (p & 1) (res *= n) %= mod;
    (n *= n) %= mod;
    p >>= 1;
  }
  return res;
}
ll BabyStepGiantStep(ll p, ll g, ll y) {
  ll m = std::ceil(std::sqrt(p));
  std::map<ll, ll> map;
  ll gj = 1;
  for (ll j = 0; j < m; ++j) {
    map[gj] = j;
    (gj *= g) %= p;
  }
  ll gm = powMod(g, p - 1 - m, p);
  ll ga = y;
  for (ll i = 0; i < m; ++i) {
    auto it = map.find(ga);
    if (it != map.end()) return i * m + it->second;
    (ga *= gm) %= p;
  }
  return -1;
}
signed main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  ;
  ll k;
  MACRO_VAR_Scan(k);
  ;
  std::vector<ll> b(k);
  for (auto& i : b) std::cin >> i;
  ;
  ll n, m;
  MACRO_VAR_Scan(n, m);
  ;
  MatrixMOD<ll> A(k, k);
  for (ll i = 0; i < ll(k - 1); ++i) A[i][i + 1] = 1;
  for (ll i = 0; i < ll(k); ++i) A[k - 1][i] = b[k - i - 1];
  A ^= n - k;
  ll t = A[k - 1][k - 1];
  ll s = BabyStepGiantStep(MOD, 3, m);
  ll d = gcd(t, MOD_);
  if (s % d != 0) {
    std::cout << (-1);
    std::cout << "\n";
    ;
    return 0;
  }
  ll x = BabyStepGiantStep(MOD, powMod(3, t, MOD), m);
  std::cout << (powMod(3, x, MOD));
  std::cout << "\n";
  ;
  return 0;
}
