#include using namespace std::literals::string_literals; using i64 = std::int_fast64_t; using std::cerr; using std::cin; using std::cout; using std::endl; #if defined(DONLINE_JUDGE) #define NDEBUG #elif defined(ONLINE_JUDGE) #define NDEBUG #endif template std::vector make_v(size_t a) { return std::vector(a); } template auto make_v(size_t a, Ts... ts) { return std::vector(ts...))>(a, make_v(ts...)); } int main() { int n; scanf("%d", &n); std::vector a(n); for (auto& v : a) scanf("%d", &v); std::vector mins(n + 1, 1 << 30); for (int i = n - 1; i >= 0; --i) mins[i] = std::min(mins[i + 1], a[i]); const int MOD = 998244353; i64 ans = 1; int last = -1; for (int i = 0; i < n; ++i) { if (mins[i] != a[i]) continue; if (last != -1) { ans = ans * (i - last + 1) % MOD; } last = i; } printf("%lld\n", ans); return 0; }