fun main() { val builder = StringBuilder() val mod = 1000000007L val (n, m) = readInputLine().split(" ").map { it.toInt() } // value -> cnt val vCnt = Array(n) { mutableMapOf() } val rCnt = Array(m) { mutableMapOf() } readInputLine().split(" ").forEachIndexed { index, s -> val v = s.toLong() if (index != 0) { vCnt[index - 1].forEach { vCnt[index][it.key] = ((vCnt[index][it.key] ?: 0L) + it.value) % mod vCnt[index][it.key + v] = ((vCnt[index][it.key + v] ?: 0L) + it.value) % mod } } vCnt[index][v] = (vCnt[index][v] ?: 0L) + 1L } readInputLine().split(" ").forEachIndexed { index, s -> val r = s.toLong() if (index != 0) { rCnt[index - 1].forEach { rCnt[index][it.key] = ((rCnt[index][it.key] ?: 0L) + it.value) % mod rCnt[index][it.key + r] = ((rCnt[index][it.key + r] ?: 0L) + it.value) % mod } } rCnt[index][r] = (rCnt[index][r] ?: 0L) + 1L } val (a, b) = readInputLine().split(" ").map { it.toLong() } var ans = 0L val vCntSum = LongArray(100000 + 1) vCnt[n - 1].forEach { entry -> vCntSum[entry.key.toInt()] = entry.value } for (i in 1..100000) { vCntSum[i] = (vCntSum[i] + vCntSum[i - 1]) % mod } rCnt[m - 1].forEach { entry -> val l = entry.key * a val r = entry.key * b ans = (ans + (vCntSum[r.toInt()] - vCntSum[l.toInt() - 1]) * entry.value) % mod } builder.appendln(ans) print(builder.toString()) } fun readInputLine(): String { return readLine()!! }