import sys input = lambda :sys.stdin.readline()[:-1] ni = lambda :int(input()) na = lambda :list(map(int,input().split())) yes = lambda :print("yes");Yes = lambda :print("Yes");YES = lambda : print("YES") no = lambda :print("no");No = lambda :print("No");NO = lambda : print("NO") ####################################################################### mod = 998244353 n = ni() a = na() f = [n-1] * n for i in range(n-2, -1, -1): if a[i] > a[f[i+1]]: f[i] = f[i+1] else: f[i] = i dp = [0] * (n+1) dp[-1] = 1 rui = [0] * (n+1) rui[-1] = 1 for i in range(n-1,-1,-1): dp[i] = rui[f[i]+1] rui[i] = (rui[i+1] + dp[i])%mod print(dp[0])