AlgoUniversity
  • Go Back
Discussion
Multiply Sums :

Author

Gigaliths

Difficulty Level : Easy

Submissions : 647

Asked In : JP-Morgan

Marks :10

: 2 | : 2

We are given an array which contains integers in ascending order followed by integers in descending order.

All the integers in the array are unique and do not occur multiple times.

Can you find out the product of the sum of values in ascending part and descending part modulo $$$10^9+7$$$.

Input

First line contains a single integer corresponding to integer N.

Second line contains N space separated integers corresponding to the values in the given array.

Constraints

$$$ 3 \le N \le 100000 $$$

$$$ 1 \le arr[i] , X \le 10^9 $$$

Output

A single integer corresponding to the product of sum of ascending and descending parts of the array.

Example

Input
7
3 8 14 12 10 7 4
Output
1175

You need to login to view your submissions.

You need to login to view all submissions.

Loading...

Result : Executed

Loading...

Feel something is wrong with the test cases?

Result : Accepted

Test Cases :

You need to Log In
We're glad that you want to attempt this problem!

But to Run or Submit the Problem, you need to Log In.

Continue to Log In
Challenge Submitted!

Your challenge has been submitted successfully.

You will get a response soon via WhatsApp or Email.

Challenge
Facing issue while trying to solve the problem! Don't worry, we got you covered!

Do let us know your issue.

Looks good!
Please enter your issue / feedback.

How do we get in touch with you?
Looks good!
Please enter your phone no.
Looks good!
Please enter your email address.