Problem: You have c_1 letters 'a', c_2 letters 'b', ..., c_{26} letters 'z'. You want to build a beautiful string of length n from them (obviously, you cannot use the i-th letter more than c_i times). Each c_i is greater than n/3.

A string is called beautiful if there are no palindromic contiguous substrings of odd length greater than 1 in it. For example, the string "abacaba" is not beautiful, it has several palindromic substrings of odd length greater than 1 (for example, "aca"). Another example: the string "abcaa" is beautiful.

Calculate the number of different strings you can build, and print the answer modulo 998244353.

Input

The first line contains one integer n (3 ≤ n ≤ 400).

The second line contains 26 integers c_1, c_2, ..., c_{26} (n/3 < c_i ≤ n).

Output

Print one integer — the number of strings you can build, taken modulo 998244353.

Examples

Input


4
2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2


Output


422500


Input


3
2 2 2 2 2 2 3 3 3 2 2 2 2 2 2 3 3 3 2 2 3 2 2 3 2 2


Output


16900


Input


400
348 322 247 158 209 134 151 267 268 176 214 379 372 291 388 135 147 304 169 149 193 351 380 368 181 340


Output


287489790

Solution (in CPP):

Solution:
#include<bits/stdc++.h>
#define long long long
using namespace std;


//#pragma GCC optimize ("O3")
//#pragma GCC target ("sse4")


mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int N=1e6,inf=1e9,mod=998244353;

int n;
int dp[2][400+2][400+2][4][4],dp2[2][400+2][3][3];
int a[N+2];
int main()
{
  ios_base::sync_with_stdio(0);cin.tie(0);

  int n;cin>>n;
  for(int f1=0;f1<=3;f1++)for(int f2=0;f2<=3;f2++)dp[(n+1)%2][0][0][f1][f2]=1;

  for(int i=n;i>=1;i--)
  {
    for(int a=0;a<=400;a++)
    {
      for(int b=0;b<=400;b++)
      {
        for(int f1=0;f1<=3;f1++)
        {
          for(int f2=0;f2<=3;f2++)
          {
            int id=i%2;long ret=0;
            int rd=(id^1);
            if(f1==0)
            {
              ret+=24LL*dp[rd][a][b][f2][3];
              if(a)ret+=dp[rd][a-1][b][f2][1];
              if(b)ret+=dp[rd][a][b-1][f2][2];
            }
            else if(f1==1)
            {
              ret+=24LL*dp[rd][a][b][f2][3];
              if(b)ret+=dp[rd][a][b-1][f2][2];
            }
            else if(f1==2)
            {
              ret+=24LL*dp[rd][a][b][f2][3];
              if(a)ret+=dp[rd][a-1][b][f2][1];
            }
            else
            {
              ret+=23LL*dp[rd][a][b][f2][3];
              if(a)ret+=dp[rd][a-1][b][f2][1];
              if(b)ret+=dp[rd][a][b-1][f2][2];
            }
            ret%=mod;
            dp[id][a][b][f1][f2]=ret;
          }
        }
      }
    }
  }


  for(int f1=0;f1<=2;f1++)for(int f2=0;f2<=2;f2++)dp2[(n+1)%2][0][f1][f2]=1;

  for(int i=n;i>=1;i--)
  {
    for(int a=0;a<=400;a++)
    {
      for(int f1=0;f1<=2;f1++)
      {
        for(int f2=0;f2<=2;f2++)
        {
          int id=i%2;long ret=0;
          int rd=(id^1);
          if(f1==0)
          {
            ret+=25LL*dp2[rd][a][f2][2];
            if(a)ret+=dp2[rd][a-1][f2][1];
          }
          else if(f1==1)
          {
            ret+=25LL*dp2[rd][a][f2][2];
          }
          else
          {
            ret+=24LL*dp2[rd][a][f2][2];
            if(a)ret+=dp2[rd][a-1][f2][1];
          }
          ret%=mod;
          dp2[id][a][f1][f2]=ret;
        }
      }
    }
  }

  for(int i=1;i<=26;i++)cin>>a[i];

  long tt=26*26;
  for(int i=3;i<=n;i++)
    tt=(tt*25)%mod;

  //cout<<tt<<endl;
  //cout<<"*"<<dp2[1][200][0][0]<<endl;

  for(int i=1;i<=26;i++)
  {
    for(int ii=a[i]+1;ii<=400;ii++)
    {
      tt=(tt-dp2[1][ii][0][0]+mod)%mod;
    }
  }

  for(int i=1;i<=26;i++)
  {
    for(int j=i+1;j<=26;j++)
    {
      for(int ii=a[i]+1;ii<=400;ii++)
      {
        for(int jj=a[j]+1;jj<=400;jj++)
        {
          tt=(tt+dp[1][ii][jj][0][0]+mod)%mod;
        }
      }
    }
  }
  cout<<tt<<endl;

  return 0;
}