#SP0000253. Pha trà (Tea Blend)
Bài tập thuộc lộ trình
Mục lục đề ⌄
Pha trà (Tea Blend)
Tea Blend
Source: Codeforces
Version: Phuoc Hung OJ Extended
Problem Statement
There are tea packs indexed in purchase order, with positive integer strengths .
To brew a blend, the brewer combines one portion from each of the first packs, then adds one more portion from pack . The index may be among the first ; in that case pack is used twice. The blend strength is
A blend is capricious if has an odd number of positive divisors. Count the ordered index pairs with producing capricious blends. Different index pairs are distinct even if they yield the same strength.
Input
The first line contains , the number of tea packs.
The second line contains exactly integers in order.
Output
Print a single 64-bit integer: the number of pairs for which has an odd number of positive divisors. No modulo is applied.
Subtasks
- Subtask 1 (20 points): ; for every .
- Subtask 2 (30 points): ; for every .
- Subtask 3 (50 points): ; for every .
Examples
Input
4
2 3 6 4
Output
4
Explanation
Removing even prime exponents, the square-free signatures of the four strengths correspond to . The signatures of the four nonempty prefix products are .
The product is a perfect square exactly when these two signatures coincide. The four choices of match respectively prefixes, producing valid pairs.