Kozak Vus and NSD
Cossack Vus has an array consisting of integers. He learns about another array , which also has integers, but he doesn't know the values of . To determine the array , Vus can perform the following operation any number of times:
- Select two integers . - Discover the sum . - Pay coins, where is the greatest common divisor (e.g., , and ).
Vus wants you to find the minimum number of coins needed to determine the array .
Additionally, Vus will change a certain number to a total of times. After each change, you need to find the minimum number of coins required for the updated array.
Input
The first line contains two integers and — the number of elements in the array and the number of changes to the array.
The second line contains integers — the elements of the array.
The next lines each contain two integers and — the index of the element in the array that is changed and the new value it is changed to.
Output
Output numbers — for each version of the array , find the minimum number of coins needed to determine the array .
The first number is the answer for the initial array .
The next numbers are the answers for each update of the array.
Examples
Scoring
( points): ;
( points): ;
( points): ;
( points): ;
( points): ;
( points): ;
( points): no additional constraints.