#P5686. Sequence Sum Product
Sequence Sum Product
Sequence Sum Product
Given two sequences \(a_i\) and \(b_i\) indexed from \(1\) to \(n\), define a function \(S(l,r)\) for \(1 \leq l \leq r \leq n\) as:
\(S(l,r) = \left(\sum_{i=l}^{r} a_i\right) \times \left(\sum_{i=l}^{r} b_i\right)\)
Your task is to compute the value of:
\(\sum_{l=1}^{n} \sum_{r=l}^{n} S(l,r)\)
Since the answer may be very large, output it modulo \(10^9+7\).
inputFormat
The first line contains a single integer \(n\), the length of the sequences. The second line contains \(n\) integers \(a_1, a_2, \dots, a_n\). The third line contains \(n\) integers \(b_1, b_2, \dots, b_n\).
outputFormat
Output a single integer, the result of the summation modulo \(10^9+7\).
sample
2
1 2
3 4
32