#include <bits/stdc++.h>
using namespace std;

typedef long long int ll;
const ll MOD = 998244353;

ll mypow(ll a, ll r) {
    ll ans = 1;
    while (r > 0) {
        if (r&1)
            ans = ans * a % MOD;
        r >>= 1;
        a = a * a % MOD;
    }
    return ans;
}

int n;
int M;

ll dp[202][4], mydp[202][4];
void make_dp(int n) {
    for (int i = 0; i <= M; i++)
        dp[i][0] = dp[i][1] = dp[i][2] = dp[i][3] = 0;
    dp[0][0] = 25;
    dp[1][1] = 1;

    for (int i = 1; i < n; i++) {
        swap(dp, mydp);
        for (int j = 0; j <= M; j++)
            dp[j][0] = dp[j][1] = dp[j][2] = dp[j][3] = 0;
        
        for (int j = 0; j <= M; j++) {
            if (i == 1) {
                dp[j][0] = (mydp[j][0] * 25 + mydp[j][2] * 25) % MOD;
                dp[j][2] = (mydp[j][1] * 25 + mydp[j][3] * 25) % MOD;
            }
            else {
                dp[j][0] = (mydp[j][0] * 24 + mydp[j][2] * 25) % MOD;
                dp[j][2] = (mydp[j][1] * 24 + mydp[j][3] * 25) % MOD;
            }
            if (j < M) {
                dp[j + 1][1] = mydp[j][0];
                dp[j + 1][3] = mydp[j][1];
            }
        }
    }
}

ll dp2[202][202][9], mydp2[202][202][9];
void make_dp2(int n) {
    for (int i = 0; i <= M; i++)
        for (int i2 = 0; i2 <= M; i2++)
            for (int j = 0; j < 9; j++)
                dp2[i][i2][j] = 0;
    dp2[0][0][0] = 24;
    dp2[1][0][1] = 1;
    dp2[0][1][2] = 1;
    
    for (int i = 1; i < n; i++) {
        swap(dp2, mydp2);
        for (int j = 0; j <= M; j++)
            for (int j2 = 0; j2 <= M; j2++)
                for (int s = 0; s < 9; s++)
                    dp2[j][j2][s] = 0;
        
        for (int j = 0; j <= M; j++)
            for (int j2 = 0; j2 <= M; j2++) {
                if (i == 1) {
                    for (int s = 0; s < 3; s++)
                        dp2[j][j2][3*s] = (mydp2[j][j2][s] * 24 + mydp2[j][j2][3+s] * 24 + mydp2[j][j2][6+s] * 24) % MOD;
                }
                else {
                    for (int s = 0; s < 3; s++)
                        dp2[j][j2][3*s] = (mydp2[j][j2][s] * 23 + mydp2[j][j2][3+s] * 24 + mydp2[j][j2][6+s] * 24) % MOD;
                }
                if (j < M) {
                    dp2[j + 1][j2][1] = (mydp2[j][j2][0] + mydp2[j][j2][6]) % MOD;
                    dp2[j + 1][j2][4] = (mydp2[j][j2][1] + mydp2[j][j2][7]) % MOD;
                    dp2[j + 1][j2][7] = (mydp2[j][j2][2] + mydp2[j][j2][8]) % MOD;
                }
                if (j2 < M) {
                    dp2[j][j2 + 1][2] = (mydp2[j][j2][0] + mydp2[j][j2][3]) % MOD;
                    dp2[j][j2 + 1][5] = (mydp2[j][j2][1] + mydp2[j][j2][4]) % MOD;
                    dp2[j][j2 + 1][8] = (mydp2[j][j2][2] + mydp2[j][j2][5]) % MOD;
                }
            }
        
    }
}

ll vio_1(int n, int k) {
    ll ans = 0;
    for (int i = k + 1; i <= M; i++)
        ans = (ans + dp[i][0] + dp[i][1] + dp[i][2] + dp[i][3]) % MOD;
    // cout << k << " " << ans << "\n";
    return ans;
}

ll vio_2(int n, int k1, int k2) {
    ll ans = 0;
    for (int i = k1 + 1; i <= M; i++)
        for (int j = k2 + 1; j <= M; j++)
            for (int t = 0; t < 9; t++) {
                ans += dp2[i][j][t];
                if (ans >= MOD)
                    ans -= MOD;
            }
    return ans;
}
    
int A[26];

int main() {
    cin >> n;
    M = (int)( (int)((n+1)/2)+1)/2 + (int) ((n+2)/4);
    make_dp(n);
    make_dp2(n);
    for (int i = 0; i < 26; i++) {
        cin >> A[i];
    }
    if (n == 1) {
        cout << 26 << "\n";
        return 0;
    }
    ll ans = 26 * 26 * mypow(25ll, (int)((n+1)/2)+(int)(n/2)-2ll) % MOD;
    for (int i = 0; i < 26; i++) {
        ans = ans + MOD - vio_1(n, A[i]);
        if (ans >= MOD)
            ans -= MOD;
        for (int j = i + 1; j < 26; j++) {
            ans = ans + vio_2(n, A[i], A[j]);
            if (ans >= MOD)
                ans -= MOD;
        }
    }
    cout << ans << "\n";
}
