Under construction

Still being built. Things may change

Gathering the Followers

Interview

Time limit2sMemory limit1024 MB

Summary
Given each follower's visit period d_i and the weekday s of the last joint meeting, find the weekday of the next joint meeting.
Level

Easy3 of 10

Topics
Math, Number theory
Solved
No attempts yet

Statement

Grindelwald wants to gather his followers. However, he cannot do it on just any day. Grindelwald has nn followers, numbered from 1 to nn. Follower ii visits the meeting place every did_i days, based on personal beliefs (that is, the interval between two consecutive visits by follower ii is did_i days). Grindelwald remembers that the last time all his followers appeared at the meeting place together, it was on day ss of the week. Help him find the number of the day of the week on which all followers will next be at the meeting place together.

Input

The first line contains two integers nn and ss (1≤n≤1051 \le n \le 10^5, 1≤s≤71 \le s \le 7). The second line contains nn integers did_i (1≤di≤201 \le d_i \le 20).

Output

Print a single integer from 1 to 7: the number of the day of the week on which all followers will next be at the meeting place together. A week has 7 days, which Grindelwald numbered from 1 to 7 in order.

Examples1

  1. Example 1

    Input
    3 1
    2 5 10
    
    Expected output
    4