import sequtils,strutils,algorithm,math,sugar,macros,strformat template get*():string = stdin.readLine().strip() const INF = 10_0000_0007 let n = get().parseInt() let A = newSeqWith(n+1,get().parseInt()) let B = newSeqWith(n+1,get().parseInt()) var bSum = B.foldl((a+b) mod INF,0) var ans = 0 for i,a in A: ans = (ans + a * bSum) mod INF bSum = (bSum - B[^(1+i)] + INF) mod INF echo ans