##################################################################################################### ##### ラグランジュ補間 ##################################################################################################### """ 計算量: O(N^2) 参考: https://ferin-tech.hatenablog.com/entry/2019/08/11/%E3%83%A9%E3%82%B0%E3%83%A9%E3%83%B3%E3%82%B8%E3%83%A5%E8%A3%9C%E9%96%93 ベンチマーク: F - Polynomial Construction: https://atcoder.jp/contests/abc137/submissions/22574915 """ def convolution(F,a): """ return: f(x)*(x-a) """ _N=len(F) res=[0]+F[:] for i in range(_N)[::-1]: res[i]+=F[i]*(-a) res[i]%=MOD return res def division(F,a): """ return: f(x)/(x-a)の 商, 余り """ res=[0]*len(F) res[-1]=F[-1] for i in range(len(F)-1)[::-1]: res[i]=(F[i]+a*res[i+1]) res[i]%=MOD return res[1:], res[0] def evaluation(F,a): """ :return: F(a) """ q,r=division(F,a) return r def FindFunction(A,B): def gcd_ext(a0,b0): a,b=abs(a0),abs(b0) sign_a,sing_b=(a0>0)-(a0<0),(b0>0)-(b0<0) x0,y0,x,y=0,1,1,0 while b!=0: q=a//b a,b=b,a%b x0,y0,x,y=x-q*x0,y-q*y0,x0,y0 return (x*sign_a,y*sing_b) def mod_inv(a,MOD): """ gcd(a,MOD)=1 を満たす必要あり """ x,y=gcd_ext(a,MOD) return x%MOD _N=len(A) F=[1] for a in A: F=convolution(F,a) Fs=[] for a in A: q,r=division(F,a) Fs.append(q) C=[] for i,b in enumerate(B): val=evaluation(Fs[i],A[i]) C.append(b*mod_inv(val,MOD)%MOD) res=[0]*(_N) for c,F in zip(C,Fs): for i,p in enumerate(F): if i>=_N: continue res[i]+=c*p res[i]%=MOD return res ####################################################################### MOD=998244353 N=int(input()) A=list(map(int, input().split())) f=[1] for a in A: f=convolution(f,a) f=convolution(f,-a) print(f) C=[] for a in A: q,r=division(f,a) C.append(evaluation(q,a)) print(C) res=0 sign=pow(-1,(N-1)%2) for c in C: res+=pow(c,MOD-2,MOD)*sign res%=MOD print(res*2%MOD)