p = 998244353 N = int(input()) A = list(map(int,input().split())) A.insert(0,0) a = 1 i = 0 while i