#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
const int N = 1e3 + 5, mol = 998244353, M = 2e4;
int n;
int q[N];
int dp[N][2*M+5], ans;
signed main()
{
ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
cin >> n;
for(int i = 1; i <= n ; i ++) cin >> q[i];
for(int i = 1; i <= n ; i ++)
{
ans ++;
for(int j = 1; j < i ; j ++)
{
dp[i][q[i] - q[j] + M] += dp[j][q[i]-q[j] + M] + 1;
dp[i][q[i] - q[j] + M] %= mol;
ans += dp[j][q[i]-q[j] + M] + 1;
ans %= mol;
}
}
cout << ans << endl;
return 0;
}
我比较疑惑的是为什么用dp[j][q[i]-q[j] + M] + 1作为对ans的贡献,而不是用dp[i][q[i] - q[j] + M]