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

#ifdef LOCAL
#define debug(var) cerr << (#var) << " = " << (var) << endl;
#else
#define debug(var)
#endif

void init() {
  ios_base::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
}

const int mod = 998244353;
const int N = 1e5+23;

int h[N];

long long binpow(long long b, long long e) {
  if (!e) return 1;
  if (e&1) return b*binpow(b, e-1)%mod;
  return binpow(b*b%mod, e/2);
}

void solve() {
  int n; scanf("%d", &n);
  for (int d, i = 0; i < n; ++i) {
    scanf("%d", &d);
    if (!i && d) {
      puts("0");
      return;
    }
    ++h[d];
  }
  if (h[0] > 1) {
    puts("0");
    return;
  }
  long long ans = 1;
  for (int i = 0; i < n-1; ++i) {
    if (!h[i] && h[i+1]) {
      puts("0");
      return;
    }
    (ans *= binpow(h[i], h[i+1])) %= mod;
  }
  printf("%lld", ans);
}

int main() {
  init();
  int t = 1; //scanf("%d", &t);
  while (t--) {
    solve();
  }
  return 0;
}

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

using i32 = std::int_fast32_t;
using i64 = std::int_fast64_t;

#define REP(i, stop) FOR(i, 0, stop)
#define FOR(i, start, stop) for (int i = start, i##_len = stop; i < i##_len; ++i)
#define RREP(i, n) for (int i = n; i-- > 0;)

i32 M = 998244353;
i32 dp[90310];
i32 dq[90310];

signed main() {
  i32 n;
  scanf("%d", &n);
  vector<i32> A(n);
  i32 sum = 0;
  REP(i, n) {
    scanf("%d", &A[i]);
    sum += A[i];
  }
  i32 lim = (sum - 1) / 2;
  dp[0] = 1;
  dq[0] = 1;
  REP(i, n) {
    RREP(t, 90000) {
      (dp[t + A[i]] += dp[t]) %= M;
      (dp[t] *= 2) %= M;
      (dq[t + A[i]] += dq[t]) %= M;
    }
  }
  i32 ans = 1;
  REP(i, n) {
    ans = (ans * 3) % M;
  }
  FOR(t, lim + 1, 90000) {
    ans = (ans - dp[t] * 3) % M;
  }
  if (sum % 2 == 0) {
    ans = (ans + dq[sum / 2] * 3) % M;
  }
  ans = (ans + M) % M;
  printf("%d\n", ans);
}