atcoder#ARC134E. [ARC134E] Modulo Nim

[ARC134E] Modulo Nim

Score : 900900 points

Problem Statement

Snuke found a blackboard with nothing written on it.

He will do NN operations on this blackboard. In the ii-th operation, he chooses an integer between 11 and aia_i (inclusive) and writes it on the blackboard.

After NN integers are written on the blackboard, Taro The First and Jiro The Second will play a game using it. In the game, the two alternately do the operation below, with Taro The First going first.

  • Let XX be the largest integer written on the blackboard.- If X=0X=0, the current player wins and the game ends.
  • If X=0X=0, the current player wins and the game ends.
  • Choose an integer mm between 11 and XX (inclusive).
  • Replace each of the NN integers written on the blackboard with its remainder when divided by mm.

There are i=1Nai\prod_{i=1}^{N}a_i ways for Snuke to write numbers on the blackboard. Find the number of ways among them that will result in Taro The First's win if both players play optimally, modulo 998244353998244353.

Constraints

  • All values in input are integers.
  • 1N2001 \leq N \leq 200
  • 1ai2001 \leq a_i \leq 200

Input

Input is given from Standard Input in the following format:

NN

a1a_1 a2a_2 \cdots aNa_N

Output

Print the number of ways to write integers that will result in Taro The First's win if both players play optimally, modulo 998244353998244353.

1
3
1
  • Taro The First will win only if Snuke writes 33.
  • Otherwise, Taro The First can only play a move that makes the integer on the blackboard 00.
2
5 10
47
20
200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200
273710435
  • Be sure to find the count modulo 998244353998244353.