#include <bits/stdc++.h>
#ifdef ALGO
#include "el_psy_congroo.hpp"
#else
#define DUMP(...) 1145141919810
#define CHECK(...) (__VA_ARGS__)
#endif

template<int MOD>
struct Integral {
  int v_ = 0;

  template<typename T> Integral(T v) : v_(norm(v)) {  // Implicit conversion is allowed.
    static_assert(std::is_integral<T>::value, "input should be an integral.");
  }
  Integral() = default;
  ~Integral() = default;

  template<typename T> T norm(T v) const {
    if constexpr(std::is_same<long long, T>::value) {
      v %= MOD;
      if (v < 0) v += MOD;
    } else {
      if (v >= MOD) v -= MOD;
      if (v < 0) v += MOD;
      if (v >= MOD || v < 0) {
        v %= MOD;
        if (v < 0) v += MOD;
      }
    }
    return v;
  }

  int val() const { return v_; }
  Integral& operator += (const Integral& rhs) { v_ += rhs.val(); if (v_ >= MOD) v_ -= MOD; return *this; }
  Integral& operator -= (const Integral& rhs) { v_ += MOD - rhs.val(); if (v_ >= MOD) v_ -= MOD; return *this; }
  Integral& operator *= (const Integral& rhs) { v_ = v_ * 1LL * rhs.val() % MOD; return *this; }
  Integral& operator /= (const Integral& rhs) { v_ = v_ * 1LL * rhs.inv().val() % MOD; return *this; }
  Integral operator + (const Integral& rhs) const { Integral ret = *this; return ret += rhs; }
  Integral operator - (const Integral& rhs) const { Integral ret = *this; return ret -= rhs; }
  Integral operator * (const Integral& rhs) const { Integral ret = *this; return ret *= rhs; }
  Integral operator / (const Integral& rhs) const { Integral ret = *this; return ret /= rhs; }
  bool operator == (const Integral& rhs) const { return val() == rhs.val(); }
  bool operator != (const Integral& rhs) const { return !(*this == rhs); }
  const Integral operator - () const { return Integral(-val()); }
  const Integral& operator ++ () { v_ += 1; if (v_ >= MOD) v_ -= MOD; return *this; }
  const Integral operator ++ (int) { Integral ret = *this; ++(*this); return ret; }
  const Integral& operator -- () { v_ += MOD - 1; if (v_ >= MOD) v_ -= MOD; return *this; }
  const Integral operator -- (int) { Integral ret = *this; --(*this); return ret; }

  Integral power(long long b) const {
    long long ret = 1 % MOD, a = v_;
    for ( ; b; b >>= 1, a = a * a % MOD) if (b & 1) ret = ret * a % MOD; return ret;
  }
  Integral inv() const { return power(MOD - 2); }
};

template<int MOD>
std::string to_string(const Integral<MOD>& v) {
  return std::string("{") + std::to_string(v.val()) + "}";
}

template<int MOD, bool kAllowBruteForce = false>
struct Binomial {
  std::vector<Integral<MOD>> factor, inv_factor;

  explicit Binomial(int n = 0) : factor(n + 1), inv_factor(n + 1) {
    factor[0] = 1;
    for (int i = 1; i <= n; ++i) factor[i] = factor[i - 1] * i;
    inv_factor[n] = factor[n].inv();
    for (int i = n; i >= 1; --i) inv_factor[i - 1] = inv_factor[i] * i;
  }
  ~Binomial() = default;

  template<typename T>
  Integral<MOD> operator () (T a, T b) const {
    if (a < b || b < 0) return 0;
    if (a < factor.size()) return factor[a] * inv_factor[b] * inv_factor[a - b];
    if constexpr(!kAllowBruteForce) {
      throw std::out_of_range("Binomial");
    } else {
      b = std::min(b, a - b);
      Integral<MOD> ret = 1;
      for (T i = 1; i <= b; ++i) ret = ret * (a + 1 - i) / i;
      return ret;
    }
  }
};

template<int MOD>
struct PowerTable : public std::vector<Integral<MOD>> {
  PowerTable(int n, const Integral<MOD>& g) {
    static_assert(sizeof(PowerTable) == sizeof(std::vector<Integral<MOD>>), "");
    this->resize(n + 1);
    this->at(0) = 1;
    this->at(1) = g;
    for (int i = 2; i < this->size(); ++i) this->at(i) = this->at(i - 1) * this->at(1);
  }
};

const int MOD = 998244353;
using Mint = Integral<MOD>;
using Binom = Binomial<MOD>;

Binom binom(400);
// PowerTable<MOD> pw2(200000, 2);

int n;
int c[26];

using State = std::array<Mint[400 + 5][3][3], 400 + 5>;

State dp[2];

int solve() {
  State& f = dp[0];
  State& g = dp[1];
  f[0][0][0][0] = 1;
  for (int at = 0; at < n; ++at) {
    for (int i = 0; i <= at; ++i) {
      for (int j = 0; i + j <= at; ++j) {
        for (int A = 0; A < 3; ++A) {
          for (int B = 0; B < 3; ++B) if (f[i][j][A][B].val()) {
            const Mint& val = f[i][j][A][B];
            if (at < 2 || A != 0) {
              g[i + 1][j][B][0] += val;
            }
            if (at < 2 || A != 1) {
              g[i][j + 1][B][1] += val;
            }
            g[i][j][B][2] += val * (at >= 2 && A == 2 ? 23 : 24);
          }
        }
      }
    }
    f.swap(g);
    memset(&g, 0, sizeof(State));
  }
  Mint result = 0;
  for (int i = 0; i <= n; ++i) {
    for (int j = 0; i + j <= n; ++j) {
      for (int A = 0; A < 3; ++A) {
        for (int B = 0; B < 3; ++B) {
          result += f[i][j][A][B];
        }
      }
    }
  }
  for (int C = 0; C < 26; ++C) {
    for (int i = c[C] + 1; i <= n; ++i) {
      for (int j = 0; i + j <= n; ++j) {
        for (int A = 0; A < 3; ++A) {
          for (int B = 0; B < 3; ++B) {
            result -= f[i][j][A][B];
          }
        }
      }
    }
  }
  for (int C = 0; C < 26; ++C) {
    for (int D = C + 1; D < 26; ++D) {
      for (int i = c[C] + 1; i <= n; ++i) {
        for (int j = c[D] + 1; i + j <= n; ++j) {
          for (int A = 0; A < 3; ++A) {
            for (int B = 0; B < 3; ++B) {
              result += f[i][j][A][B];
            }
          }
        }
      }
    }
  }
  return result.val();
}

int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  std::istream& reader = std::cin;

  reader >> n;
  for (int i = 0; i < 26; ++i) {
    reader >> c[i];
  }
  std::cout << solve() << std::endl;
}

