PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN

#GL0000224. Đếm dãy có ƯCLN tiền tố cho trước (Count GCD)

HỌC THEO LỘ TRÌNH

Bài tập thuộc lộ trình

1 lộ trình

Đếm dãy có ƯCLN tiền tố cho trước (Count GCD)

Count GCD

Source: Codeforces

Version: Phuoc Hung OJ Extended

Problem Statement

Given n,mn,m and a1,…,ana_1,\ldots,a_n with 1≤ai≤m1\le a_i\le m, count arrays b1,…,bnb_1,\ldots,b_n such that 1≤bi≤m1\le b_i\le m and gcd⁡(b1,…,bi)=ai\gcd(b_1,\ldots,b_i)=a_i for every 1≤i≤n1\le i\le n. Two arrays are different if they differ at some index. Print the result modulo 998244353998244353.

Input

First line contains n,mn,m; second line contains nn integers aia_i.

Output

Print the count modulo 998244353998244353.

Subtasks

  • Subtask 1 (20 points): 1≤n≤10, 1≤ai≤m≤1001\le n\le 10,\ 1\le a_i\le m\le 100.

  • Subtask 2 (30 points): 1≤n≤2000, 1≤ai≤m≤1000001\le n\le 2000,\ 1\le a_i\le m\le 100000.

  • Subtask 3 (50 points): 1≤n≤200000, 1≤ai≤m≤10000000001\le n\le 200000,\ 1\le a_i\le m\le 1000000000.

Examples

Example 1

Input

3 5
4 2 1

Output

3

Explanation

The first two elements are forced to be b1=4b_1=4 and b2=2b_2=2. The third can be 1, 3 or 5, giving exactly three arrays.

Example 2

Input

2 1
1 1

Output

1

Explanation

Since every element lies in [1,1], the only possible array is (1,1).

Example 3

Input

5 50
2 3 5 2 3

Output

0

Explanation

A prefix GCD must divide the preceding prefix GCD. Since 3 does not divide 2, no valid array exists.