Chiaki has n integers s_0,s_1,…,s_n−1. She has defined an infinite sequence S in the following way: S_k=s_kmodn+n⋅⌊nk⌋, where k is a zero based index.
For a continuous subsequence S\[l..r], let cnt_x be the number of occurrence of x in the subsequence S\[l..r]. Then the value of S\[l..r] is defined as follows f(l,r)=∑_xx⋅cnt2_x
For two integers a and b (a≤b), Chiaki would like to find the value of (∑_a≤l≤r≤bf(l,r))mod(109+7)