给定 n n n 个整数 a 1 , a 2 , … , a n a_1, a_2, \ldots, a_n a1,a2,…,an,求它们两两相乘再相加的和,即:
S = a 1 ⋅ a 2 + a 1 ⋅ a 3 + … + a 1 ⋅ a n + a 2 ⋅ a 3 + … + a n − 2 ⋅ a n − 1 + a n − 2 ⋅ a n + a n − 1 ⋅ a n S = a_1 \cdot a_2 + a_1 \cdot a_3 + \ldots + a_1 \cdot a_n + a_2 \cdot a_3 + \ldots + a_{n-2} \cdot a_{n-1} + a_{n-2} \cdot a_n + a_{n-1} \cdot a_n S=a1⋅a2+a1⋅a3+…+a1⋅an+a2⋅a3+…+an−2⋅an−1+an−2⋅an+an−1⋅an