#include <iostream>
#include <set>

using namespace std;

const int mod = 998244353;
const int N = 402;

int add(int x, int y) {
  x += y;
  while (x >= mod)
    x -= mod;
  if (x < 0)
    x += mod;
  return x;
}

int sub(int x, int y) {
  return add(x, -y);
}

int mul(int x, int y) {
  return (x * 1ll * y) % mod;
}

int c[26];
int dp[2][N][N][3][3];  // [compressed_len, num_first_ele, num_second_ele, second_last_ele, last_ele]
int sumDp[N][N];  // [num_first_ele, num_second_ele]
int prefixDp[N][N];
int p1[N][N];
int p2[N][N];
int n;

int main() {
  cin >> n;
  for (int i = 0; i < 26; ++i)
    cin >> c[i];
  // init dp for len 3
  for (int i = 0; i < 26; ++i) {
    for (int j = 0; j < 26; ++j) {
      for (int k = 0; k < 26; ++k) {
        if (i != k) {
          multiset<int> s = {i, j, k};
          dp[1][s.count(0)][s.count(1)][min(2, j)][min(2, k)]++;
        }
      }
    }
  }
  // dp
  for (int i = 4; i <= n; ++i) {
    for (int j = 0; j < N; ++j) {
      for (int k = 0; k < N; ++k) {
        for (int x = 0; x < 3; ++x) {
          for (int y = 0; y < 3; ++y) {
            dp[0][j][k][x][y] = dp[1][j][k][x][y];
            dp[1][j][k][x][y] = 0;
          }
        }
      }
    }
    for (int j = 0; j < N; ++j) {
      for (int k = 0; k < N; ++k) {
        for (int x = 0; x < 3; ++x) {
          for (int y = 0; y < 3; ++y) {
            int cur = dp[0][j][k][x][y];
            if (0 == cur) {
              continue;
            }
            for (int z = 0; z < 3; ++z) {
              int &nw = dp[1][j + (z == 0 ? 1 : 0)][k + (z == 1 ? 1 : 0)][y][z];
              nw = add(nw, mul(cur, (z == 2 ? 24 : 1) - (z == x ? 1 : 0)));
            }
          }
        }
      }
    }
  }
  // sum of dp in the dim of first and second ending character
  for (int i = 0; i < N; ++i) {
    for (int j = 0; j < N; ++j) {
      for (int k = 0; k < 3; ++k) {
        for (int l = 0; l < 3; ++l) {
          sumDp[i][j] = add(sumDp[i][j], dp[1][i][j][k][l]);
        }
      }
    }
  }
  // 2d prefix of dp
  for (int i = N - 1; 0 <= i; --i) {
    for (int j = N - 1; 0 <= j; --j) {
      if (i == N - 1) {
        if (j == N - 1) {
          prefixDp[i][j] = sumDp[i][j];
        } else {
          prefixDp[i][j] = add(prefixDp[i][j + 1], sumDp[i][j]);
        }
      } else if (j == N - 1) {
        prefixDp[i][j] = add(prefixDp[i + 1][j], sumDp[i][j]);
      } else {
        prefixDp[i][j] = sub(add(add(prefixDp[i + 1][j], prefixDp[i][j + 1]), sumDp[i][j]) ,prefixDp[i + 1][j + 1]);
      }
    }
  }
  int ans = prefixDp[0][0];
  for (int i = 0; i < 26; ++i) {
    for (int j = 0; j < N; ++j) {
      for (int k = c[i] + 1; k < N; ++k) {
        ans = sub(ans, sumDp[k][j]);
      }
    }
  }
  for (int i = 0; i < 26; ++i) {
    for (int j = 0; j < i; ++j) {
      ans = add(ans, prefixDp[c[i] + 1][c[j] + 1]);
    }
  }
  cout << ans << endl;
  return 0;
}