#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector <int> vi;
#define pb push_back
const ll MOD = 998244353;
ll ans=0,s[405][405];
vi vc;
const int N = 405;
int dp[2][N][N][3][3],a[N],n;
inline int getmod(int x) {return (x>=MOD) ? x-MOD : x;};
void getdp()
{
    dp[0][0][0][0][0]=1;
    for (int i=0;i<n;++i)
    {
        int now=i&1,nw=now^1;
        memset(dp[nw],0,sizeof(dp[nw]));
        for (int j1=0;j1<=i;++j1)
        for (int j2=0;j2+j1<=i;++j2)
        for (int se=0;se<3;++se)
        for (int lst=0;lst<3;++lst)
        {
            if (se!=1)
            dp[nw][j1+1][j2][lst][1]=
            getmod(dp[nw][j1+1][j2][lst][1]+dp[now][j1][j2][se][lst]);
            if (se!=2)
            dp[nw][j1][j2+1][lst][2]=
            getmod(dp[nw][j1][j2+1][lst][2]+dp[now][j1][j2][se][lst]);
            if (se!=0 || i<=1)
            dp[nw][j1][j2][lst][0]=
            (24LL*dp[now][j1][j2][se][lst]+dp[nw][j1][j2][lst][0])%MOD;
            else
            dp[nw][j1][j2][lst][0]=
            (23LL*dp[now][j1][j2][se][lst]+dp[nw][j1][j2][lst][0])%MOD;
        }
    }
    for (int j1=0;j1<=n;++j1)
    for (int j2=0;j2<=n;++j2)
    {
        for (int se=0;se<3;++se)
        for (int lst=0;lst<3;++lst)
        {
            (s[j1][j2]+=dp[n&1][j1][j2][se][lst])%=MOD;
        }
    }
    for (int j1=n;j1>=0;--j1)
    for (int j2=n;j2>=0;--j2)
    {
        s[j1][j2]=(s[j1][j2]+s[j1+1][j2]+s[j1][j2+1]-s[j1+1][j2+1])%MOD;
    }
}
ll calc()
{
    int p1=0,p2=0;
    if (vc.size()>0) p1=a[vc[0]]+1;
    if (vc.size()>1) p2=a[vc[1]]+1;
    return s[p1][p2];
}
void dfs(int k,int cnt,int p)
{
    if (cnt>2) return;
    if (k>26)
    {
        (ans+=calc()*p)%=MOD;
        return;
    }
    dfs(k+1,cnt,p);
    vc.pb(k);
    dfs(k+1,cnt+1,-p);
    vc.pop_back();
}
int main()
{
    cin>>n;getdp();
    for (int i=1;i<=26;++i) cin>>a[i];
    dfs(1,0,1);
    ans=(ans%MOD+MOD)%MOD;
    cout<<ans<<endl;
    return 0;
}