Knocker

Time limit: 1s Memory limit: 256MB Input: Output:

I am the danger. A guy opens his door and gets shot, and you think that of me? No. I am the one who knocks!

  • Walter White, Breaking Bad

It's well-known that Walter is the one who knocks. But did you know that he can knock with strength xx for every positive integer xx?

He has an array a1,a2,,ana_1, a_2, \ldots, a_n of positive integers. If he knocks with strength xx, then, for each 1in1 \leq i \le n, aia_i will be replaced with aimodxa_i \bmod x.

How many different arrays a1,a2,,ana_1, a_2, \ldots, a_n can Walter achieve by knocking any number of times? As the number can be very large, output it modulo 998 244 353998 \ 244 \ 353.

Here xmodyx \bmod y denotes the remainder of xx when dividing by yy. For example, 6mod3=06 \bmod 3 = 0, and 6mod4=26 \bmod 4 = 2.

Input data

The first line of the input contains a single integer nn (1n5001 \leq n \leq 500) - the length of the array.

The second line of the input contains nn integers a1,a2,,ana_1, a_2, \ldots, a_n (1ai5001 \leq a_i \leq 500) - the elements of the array.

Output data

Output a single integer - the number of different arrays Walt can achieve by knocking.

Example 1

stdin

1
5

stdout

4

Explanation

In the first sample, you can get the following arrays: [5],[2],[1],[0][5], [2], [1], [0].

Example 2

stdin

2
6 5

stdout

7

Explanation

In the second sample, you can get the following arrays: [6,5],[2,1],[1,0],[0,5],[0,2],[0,1],[0,0][6, 5], [2, 1], [1, 0], [0, 5], [0, 2], [0, 1], [0, 0].

Example 3

stdin

5
1 2 4 8 16

stdout

69

Log in or sign up to be able to send submissions!