显示代码纯文本
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
const int INF=998244353;
int number[100010];
int main()
{
freopen("asm_formation.in","r",stdin);
freopen("asm_formation.out","w",stdout);
int n;
long long ans=1;
bool p=true;
scanf("%d",&n);
for(int i=1;i<=n;i++)
{
scanf("%d",&number[i]);
}
for(int i=n;i>0;i--)
{
if(number[i]==1) continue;
else
{
if((i-1)>0)
{
if(p==true)
{
ans=(((number[i]-1))%INF*(number[i-1])%INF)%INF+1;
p=false;
}
else
{
ans=((ans%INF)*((number[i]-1)%INF)*(number[i-1])%INF)%INF;
}
}
}
}
printf("%lld",ans);
return 0;
}