CF671C.Ultimate Weirdness of an Array

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Yasin has an array aa containing nn integers. Yasin is a 5 year old, so he loves ultimate weird things.

Yasin denotes weirdness of an array as maximum gcd(ai,aj)gcd(a_{i},a_{j}) value among all 1<=i<j<=n1<=i<j<=n . For n<=1n<=1 weirdness is equal to 00 , gcd(x,y)gcd(x,y) is the greatest common divisor of integers xx and yy .

He also defines the ultimate weirdness of an array. Ultimate weirdness is where f(i,j)f(i,j) is weirdness of the new array aa obtained by removing all elements between ii and jj inclusive, so new array is [a1... ai1,aj+1... an][a_{1}...\ a_{i-1},a_{j+1}...\ a_{n}] .

Since 5 year old boys can't code, Yasin asks for your help to find the value of ultimate weirdness of the given array aa !

输入格式

The first line of the input contains a single integer nn ( 1<=n<=2000001<=n<=200000 ) — the number of elements in aa .

The next line contains nn integers aia_{i} ( 1<=ai<=2000001<=a_{i}<=200000 ), where the ii -th number is equal to the ii -th element of the array aa . It is guaranteed that all aia_{i} are distinct.

输出格式

Print a single line containing the value of ultimate weirdness of the array aa .

输入输出样例

  • 输入#1

    3
    2 6 3
    

    输出#1

    6
    

说明/提示

Consider the first sample.

  • f(1,1)f(1,1) is equal to 33 .
  • f(2,2)f(2,2) is equal to 11 .
  • f(3,3)f(3,3) is equal to 22 .
  • f(1,2)f(1,2) , f(1,3)f(1,3) and f(2,3)f(2,3) are equal to 00 .

Thus the answer is 3+0+0+1+0+2=63+0+0+1+0+2=6 .

首页