We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
  • Hackerrank Home
  • Prepare
    NEW
  • Certify
  • Compete
  • Career Fair
  • Hiring developers?
  1. Prepare
  2. Functional Programming
  3. Ad Hoc
  4. Jumping Bunnies

Jumping Bunnies

Problem
Submissions
Leaderboard
Discussions
Editorial

Bunnies are very cute animals who likes to jump a lot. Every bunny has his own range of jump. Lets say there are bunnies and bunny jumps units. Consider a 1-D plane, where initially bunnies are at . All of them starts jumping in forward direction.

For example, consider the case of bunny. Initially he is at . After first jump, he will be at point . After second, he will be at and so on. After jump, he will be at point .

Two bunnies can only meet each other when they are on the ground. When on the ground, a bunny can wait any amount of time. Being a social animal, all of them decide to meet at the next point where all of them will be on the ground. You have to find the nearest point where all the bunnies can meet.

For example, if there are bunnies where , , . Nearest point where all bunnies can meet again is at . First bunny has to jump six times, for second it is times and for third it is times.

Help bunnies to find the nearest point where they can meet again.

Input Format
First line will contain an integer, , represeting the number of bunnies. Second line will contain space separated integer, , representing the jumping distance of them.

Output Format
Print the nearest location where all bunnies can meet again.

Constraints


For each test case it is guaranteed that solution will not exceed .

Sample Input #00

3
2 3 4

Sample Output #00

12

Sample Input #01

2
1 3

Sample Output #01

3

Explanation
Sample Case #00: This is the same example mentioned in the statement above.
Sample Case #01: First bunny has to jump times to point , whereas second bunny has to jump only one time to go at point . Point will serve as their meeting point.

Author

abhiranjan

Difficulty

Medium

Max Score

20

Submitted By

2118

Need Help?


View discussions
View editorial
View top submissions

rate this challenge

MORE DETAILS

Download problem statement
Download sample test cases
Suggest Edits
  • Blog
  • Scoring
  • Environment
  • FAQ
  • About Us
  • Support
  • Careers
  • Terms Of Service
  • Privacy Policy
  • Request a Feature