package main import ( "bufio" "os" "strconv" ) func main() { run() } func run() { setSpace() N := readN() as := make([]int, N+1) bs := make([]int, N+1) for i := 0; i < N+1; i++ { as[i] = readN() } for i := 0; i < N+1; i++ { bs[i] = readN() } // fmt.Printf("debug: %v %v\n", as, bs) cs := make([]int, len(as)+len(bs)) for ia, a := range as { for ib, b := range bs { // cs[ia+ib] = (cs[ia+ib] + a * b) % (10e9 + 7) cs[ia+ib] += a * b } } // \sum_{i=0}^n c_i sumC := 0 for i := 0; i <= N; i++ { sumC = (sumC + cs[i]) % (1e9 + 7) } println(sumC) } var sc = bufio.NewScanner(os.Stdin) func setSpace() { sc.Split(bufio.ScanWords) } func read() string { sc.Scan() return sc.Text() } func readN() int { n, err := strconv.Atoi(read()) if err != nil { panic(err) } return n }