#P8772. [蓝桥杯 2022 省 A] 求和
[蓝桥杯 2022 省 A] 求和
Problem Description
Given integers , find the sum of the products of every pair of them, that is,
$$S=a_{1} \cdot a_{2}+a_{1} \cdot a_{3}+\cdots+a_{1} \cdot a_{n}+a_{2} \cdot a_{3}+\cdots+a_{n-2} \cdot a_{n-1}+a_{n-2} \cdot a_{n}+a_{n-1} \cdot a_{n}$$Input Format
The first line contains an integer .
The second line contains integers .
Output Format
Output an integer , representing the required sum. Please use an appropriate data type for the computation.
4
1 3 6 9
117
Hint
For of the testdata, .
For all testdata, .
Lanqiao Cup 2022 NOI Qualifier A Group, Problem C.
Translated by ChatGPT 5