#Lutece1165. ModModMod (Hard Ver.)

ModModMod (Hard Ver.)

Migrated from Lutece 1165 Problem 300 in TCO Round 2A(Changed Version)

All parts of this problem, including description, images, samples, data and checker, might be broken. If you find bugs in this problem, please contact the admins.

Description

Moose Mod has just learned about the mod operator.Given two positive integers x and y, the mod operator returns the remainder when x is divided by y.For example, 17 mod 5 = 2 because 17 = 3*5 + 2.

Moose Mod has just defined a function that applies a sequence of N mod operators to its input. Formally, the function looks as follows: f(x) = (((x mod m[0]) mod m[1]) ... mod m[N-1]). For example, m = { 10, 3 } corresponds to the function f(x) = (x mod 10) mod 3. For this function we have f(18) = (18 mod 10) mod 3 = 8 mod 3 = 2.

You are given mm integers.You are also given a int RR.Moose Mod is interested in finding the sum f(1) + f(2) + ... + f(R).Compute and output its value.

Input

The first line of the input contains two integers m(1m5000)m(1\leq m\leq5000) and R(1R109)R(1\leq R\leq10^9),RR means the integer describe above and mm means the number of mods.

The second line of the input contains mm integers.The ith integer modimod_i means the ith mod.(1modi109)(1\leq mod_i\leq 10^9)

Output

Print the answer in a single line

Samples

3 10
5 3 2
4

Resources

2015 UESTC ACM Training for Math