#BS0000020. Máy sản xuất (Factory Machines)
Máy sản xuất (Factory Machines)
Factory Machines
Source: CSES
Version: Phuoc Hung OJ Extended
Problem Statement
A factory has machines. Machine needs exactly seconds to complete one product. After finishing a product, it may immediately start the next one. All machines work independently and simultaneously, and only completed products are counted. Find the minimum integer time required to produce at least products.
Input
The first line contains and . The second line contains .
Output
Print the minimum required time.
Subtasks
- Subtask 1 — 20%: .
- Subtask 2 — 30%: , .
- Subtask 3 — 50%: , , .
Examples
Input
3 7
3 2 5
Output
8
Explanation
After seconds the machines produce products.