#GD0000010. Mảng dày (Dense Array)
Mảng dày (Dense Array)
Dense Array
Source: Codeforces
Version: Phuoc Hung OJ Extended
Problem Statement
A positive integer array is dense if, for every adjacent pair, the larger value is at most twice the smaller one. You may insert positive integers anywhere without changing the order of the original elements. Find the minimum number of inserted elements needed to make the array dense.
Input
The first line contains . The second line contains .
Output
Print the minimum number of inserted elements.
Subtasks
General constraints:
-
.
-
.
-
Subtask 1 (20 points): ,
-
Subtask 2 (30 points): ,
-
Subtask 3 (50 points): No additional constraints.
Examples
Input
4
4 2 10 1
Output
5
Explanation
The pair is already dense. Two values are needed between and , and three between and , for a total of .