#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 nn. The second line contains a1,…,ana_1,\ldots,a_n.

Output

Print the minimum number of inserted elements.

Subtasks

General constraints:

  • 2≤n≤502 \le n \le 50.

  • 1≤ai≤501 \le a_i \le 50.

  • Subtask 1 (20 points): n≤10n \le 10, ai≤10a_i \le 10

  • Subtask 2 (30 points): n≤30n \le 30, ai≤30a_i \le 30

  • Subtask 3 (50 points): No additional constraints.

Examples

Input

4
4 2 10 1

Output

5

Explanation

The pair (4,2)(4,2) is already dense. Two values are needed between 22 and 1010, and three between 1010 and 11, for a total of 55.