F.A.Q
Hand In Hand
Online Acmers
Problem Archive
Realtime Judge Status
Authors Ranklist
 
     C/C++/Java Exams     
ACM Steps
Go to Job
Contest LiveCast
ICPC@China
Best Coder beta
VIP | STD Contests
    DIY | Web-DIY beta
Author ID 
Password 
 Register new ID

Mutiple

Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 1209    Accepted Submission(s): 712


Problem Description
WLD likes playing with a sequence $a[1..N]$. One day he is playing with a sequence of $N$ integers. For every index i, WLD wants to find the smallest index $F(i)$ ( if exists ), that $i < F(i) \leq n$, and $a_F(i)$ mod $a_i$ = 0. If there is no such an index $F(i)$, we set $F(i)$ as 0.
 

Input
There are Multiple Cases.(At MOST $10$)

For each case:

The first line contains one integers $N (1 \leq N \leq 10000)$.

The second line contains $N$ integers $a1,a2,...,aN(1 \leq ai \leq 10000)$,denoting the sequence WLD plays with. You can assume that all ai is distinct.
 

Output
For each case:

Print one integer.It denotes the sum of all $F(i)$ for all $1 \leq i < n$
 

Sample Input
4 1 3 2 4
 

Sample Output
6
 

Hint
F(1)=2
F(2)=0
F(3)=4
F(4)=0
 

Source
 

Statistic | Submit | Discuss | Note
Hangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2024 HDU ACM Team. All Rights Reserved.
Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
Total 0.000000(s) query 1, Server time : 2024-11-22 12:14:04, Gzip enabled