import sys import numpy as np input = sys.stdin.readline def read_values(): return map(int, input().split()) def read_index(): return map(lambda x: int(x) - 1, input().split()) def read_list(): return list(read_values()) def read_lists(N): return [read_list() for _ in range(N)] def main(): n=int(input()) a=read_list() na=np.array(a, dtype=object) a.reverse() ans=1 ans2=1 for i in range(len(a)): na=na[:-1] mul1=np.prod(na-a[i])%998244353 ans*=mul1 ans%=998244353 print(ans) if __name__ == "__main__": main()