https://codeforces.com/problemset/problem/1165/D
Input Format
Check Link
Output Format
Check Link
Constraints
Check Link
Example
Input
2 8 8 2 12 6 4 24 16 3 1 2
Output
48 4
https://codeforces.com/problemset/problem/1165/D
Check Link
Check Link
Check Link
2 8 8 2 12 6 4 24 16 3 1 2
48 4