AT_abc435_b [ABC435B] No-Divisible Range

Description

You are given a sequence of positive integers $ A=(A_1,A_2,\ldots,A_N) $ of length $ N $ . Find the number of pairs of integers $ (l,r) $ satisfying $ 1\leq l\leq r\leq N $ that satisfy the following condition: > For every integer $ i $ satisfying $ l\leq i\leq r $ , $ A_i $ is **not** a divisor of $ A_l+A_{l+1}+\cdots+A_r $ .

Input Format

The input is given from Standard Input in the following format: > $ N $ $ A_1 $ $ A_2 $ $ \ldots $ $ A_N $

Output Format

Output the answer.

Explanation/Hint

### Sample Explanation 1 We have $ A=(8,6,10,5,7) $ . For example, $ (l,r)=(1,2) $ satisfies the condition because $ A_l+A_{l+1}+\cdots+A_r=A_1+A_2=14 $ , and neither $ A_1=8 $ nor $ A_2=6 $ is a divisor of $ 14 $ . On the other hand, $ (l,r)=(1,3) $ does not satisfy the condition because $ A_l+A_{l+1}+\cdots+A_r=A_1+A_2+A_3=24 $ , and $ A_1=8 $ is a divisor of $ 24 $ . The pairs that satisfy the condition are $ (l,r)=(1,2), (1,4), (2,3), (2,4), (3,5), (4,5) $ , which is six pairs, so output $ 6 $ . ### Constraints - $ 1 \leq N \leq 50 $ - $ 1 \leq A_i \leq 1000 $ - All input values are integers.