MOD = 998244353i64 n = read_line.to_i a = read_line.split.map(&.to_i) cnt = Array.new(n + 1, 0i64) sum = Array.new(n + 1, 0i64) cnt[n] = 1 sum[n] = 1 min = a[-1] min_pos = n - 1 (n - 1).downto(0) do |i| if a[i] <= min min = a[i] min_pos = i end cnt[i] = sum[min_pos + 1] sum[i] = (sum[i + 1] + cnt[i]) % MOD end puts cnt[0]