#include #include #include #include #include #include #include #include #include #include #include #include //#include using namespace std; typedef long long ll; const ll INF=1LL<<60; typedef pair P; typedef pair PP; const ll MOD=998244353; int main(){ int N; cin>>N; vector A(N); ll maxA=-INF; ll minA=INF; for(int i=0;i>A[i]; maxA=max(maxA,A[i]); minA=min(minA,A[i]); } ll ans=0; for(ll k=1;k<=maxA-minA;k++){ /* dp[i][j]=j番目の要素がA[i]となる */ vector> dp(N+1,vector(4,0)); for(int i=0;i