PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN

#GD0000161. Biến dãy thành dãy tốt (Make Array Good)

HỌC THEO LỘ TRÌNH

Bài tập thuộc lộ trình

1 lộ trình

Biến dãy thành dãy tốt (Make Array Good)

Make Array Good

Source: Codeforces

Version: Phuoc Hung OJ Extended

Problem Statement

An array of positive integers is good if, for every pair of elements, the larger is divisible by the smaller. An operation chooses index ii and integer 0≤x≤ai0\le x\le a_i and increases aia_i by xx, keeping the new value at most 101810^{18}. Construct at most nn operations making the array good.

Input

The first line contains nn. The second line contains nn positive integers a1,…,ana_1,\ldots,a_n.

Output

Print the number of operations pp (0≤p≤n0\le p\le n), followed by pp lines, each containing the index ii and increment xx of an operation in execution order.

Subtasks

  • Subtask 1 (20 points): 1≤n≤81\le n\le 8; 1≤ai≤1091\le a_i\le 10^9; sau mỗi thao tác ai≤1018a_i\le 10^{18}.
  • Subtask 2 (30 points): 1≤n≤30001\le n\le 3000; 1≤ai≤1091\le a_i\le 10^9; sau mỗi thao tác ai≤1018a_i\le 10^{18}.
  • Subtask 3 (50 points): 1≤n≤1051\le n\le 10^5; 1≤ai≤1091\le a_i\le 10^9; sau mỗi thao tác ai≤1018a_i\le 10^{18}.

Examples

Input

4
2 3 5 5

Output

3
2 1
3 3
4 3

Explanation

Increase the second element by 11, and the third and fourth elements by 33 each. This produces [2,4,8,8][2,4,8,8], where every larger value is divisible by every smaller one. Each increment is legal, using only three operations.