Chamber of Secrets

Problem
Harry is trying to find the chamber of secrets but the chamber of secrets is well protected by dark spells. To find the chamber Harry needs to find the initial position of the chamber. Harry knows the final position of the chamber is X. He also knows that in total, the chamber has been repositioned N times. During the ith repositioning, the position of the chamber is changed to (previous position * Arr[i]) % 1000000007.
Given X and Arr, help Harry find the initial position of the chamber.

Note:- The initial position of the chamber is less than 1000000007.

Input
The first line of the input contains two integers N and X.
The second line of the input contains N integers denoting Arr.

output
Print a single integer denoting the initial position of the chamber.

Sample Input
5 480
1 4 4 3 1

Sample Output
10

Explanation
Initial position = 10
After first repositioning position = (10 * 1)%1000000007 = 10
After second repositioning position = (10 * 4)%1000000007 = 40
After third repositioning position = (40 * 4)%1000000007 = 160
After fourth repositioning position = (160 * 3)%1000000007 = 480
After fifth repositioning position = (480 * 1)%1000000007 = 480

How do i do it?