Gennady and the Bells

Revision en2, by AH-O, 2021-10-20 18:15:38

Gennady was on a tour from "Chittagong" to "Sylhet" to visit a historical Bungalow about 300 years old. There he saw many interesting things, but the only thing that could attract him were some bells. There were several bells in this Bungalow of different colors. These bells tinkle after a certain time individually.

Say there were 3 bells. Bell A tinkle after 10 minutes later, bell B tinkle after 12 minutes later, bell c tinkle after 24 minutes later.

But the interesting thing was all bells tinkle together after a certain period according to the time of their individual tinkling.

According to the tinkling time of bell A, B, C — if they tinkle together at 9:30 am, they will tinkle together again at 8:30 am

After 5 minutes of Gennady's arrival, the bells tinkled together. Gennady was curious about how many times after the bells would tinkle together? Now you have to help Gennady to find the time of tinkling together.

Input

The first line contains 2 integers a,b(2<=a<=100,1<=b<=24) define the number of bells and time of their tinkling together for the first time(remember it is a 24 hour clock time system in Gennady's country)

The second line contains some integers followed by the number of bells, defining the time of tinkling of the bells individually.

Output

You have to find, when will the bells tinkle together again.

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en2 English AH-O 2021-10-20 18:15:38 81 (published)
en1 English AH-O 2017-10-20 20:35:42 1357 Initial revision (saved to drafts)