import sequtils,strutils,algorithm,math,sugar,macros,strformat template get*():string = stdin.readLine().strip() proc getchar_unlocked():char {. importc:"getchar_unlocked",header: "" .} proc scan(): int = while true: var k = getchar_unlocked() if k < '0' or k > '9': break else: result = 10 * result + k.ord - '0'.ord const INF = 10_0000_0007 proc MOD(x:int) :int = if x > INF : x mod INF else: x let n = scan() let A = newSeqWith(n+1,scan()) let B = newSeqWith(n+1,scan()) var bSum = B.foldl(MOD(a+b),0) var ans = 0 for i,a in A: ans = MOD(ans + a * bSum) bSum -= B[^(1+i)] if bSum < 0 : bSum += INF echo ans