Sum And Product

0

0 votes
Easy
Problem

Given an array of n integers. Lets denote the elements as a1, a2, a3, ..., an. Here, ai indicates ith element. We need to find (a1 * a2) + (a3 * a4) + ..... + (an-1 * an). As the answer can be large, print the answer It is guaranteed that n is even.

Input format:-

First line contains an integer n, denoting the number of integers.

Second line contains n integers(a1, a2, ..., an). Here, ai indicates ith element.

Output format:-

Print ((a1 * a2) + (a3 * a4) + (a5 * a6) + ... + (an - 1 * an)) % (10 ^ 9 + 7) in a new line.

Constraints:-

1 <= n <= 100, n is even.

1 <= ai <= 10^18

Time Limit: 5
Memory Limit: 256
Source Limit:
Editor Image

?