Eraser
Time limit1sMemory limit256 MB
Given a sequence, add the products of every triple of entries at distinct positions with three different values, modulo 1,000,000,007.
- Level
Medium6 of 10
- Topics
- Combinatorics, Math, Array
- Solved
- No attempts yet
Problem
Seunghyun is worried that someone will ruin his erasers, so he decided to make his own.
Seunghyun picks a sequence of natural numbers . He then chooses three elements , , at three different positions of the sequence and builds a rectangular eraser whose width, depth and height are those three values. He calls it the eraser. Seunghyun likes erasers that are tall and thin, so must hold.

Look at the picture above. Let the sequence be , , , . The eraser cannot be made, because is false. The eraser can be made, because is true. The only erasers that can be made from this sequence are the eraser and the eraser.
Seunghyun wants to know the total volume of every eraser he can make. The volume of an eraser is the product of its width, depth and height. He needs that number to design the warehouse where the erasers will be stacked, so help him compute it.
Input
The first line contains the length of the sequence. ()
The second line contains in order, separated by spaces. ()
Output
Print the sum of the volumes of every eraser that can be made. Seunghyun wants to check that the program runs correctly first, so print that sum modulo ().
Hint
Take the sequence , , , . The only erasers that can be made are the eraser and the eraser, so the total volume is .