Olive solves it first!

5

1 votes
Problem

Olive solved this problem recently. Can you solve it?
Given a number n and two rows A and B of length n find a new row K for all i where K[i] stores the number of numbers in array A greater than B[i] and find the sum of product of all numbers in K taken two at a time.


INPUT
First line contains a single integer N

Next two lines each contain N space separated integers


OUTPUT
The answer may be large so
Print your final answer as (answer)%mod.
Here mod = 10^9 + 7


CONSTRAINTS
1 <= N <= 100000

For ,0 <= i <= N-1 , 0 <= Ai,Bi <= (2*100000)
 

Time Limit: 1
Memory Limit: 256
Source Limit:
Explanation

In the first array (Array A) :

Elements greater than or equal to 12 is {17}
Elements greater than or equal to 2 are {11,7,4,17,11}
Elements greater than or equal to 12 is {17}
Elements greater than or equal to 4 are {11,7,4,17,11}
Elements greater than or equal to 3 are {11,7,4,17,11}
We get the array K as (1,5,1,5,5}

Sum of product taken two at a time for elements of array K gives the result as 106.

Editor Image

?