package yukicoder import java.util.* class Main(private val args : Array) : Runnable { override fun run() { solve(args) } private fun solve(@Suppress("UNUSED_PARAMETER") args: Array) { Scanner(System.`in`).use { sc -> val T = sc.nextInt() repeat(T) { val N = sc.nextInt() val A = IntArray(N){sc.nextInt()} val MOD = 1_000_000_007 var ans = A.fold(1){l, r -> (l.toLong() * (r + 1) % MOD).toInt()} - 1 if (ans < 0) ans += MOD println(ans) } } } } /** 確保するメモリの大きさ(単位: MB) */ private const val MEMORY: Long = 64 fun main(args: Array) { Thread.setDefaultUncaughtExceptionHandler { _: Thread?, e: Throwable -> e.printStackTrace() System.exit(1) } Thread(null, Main(args = args), "", MEMORY * 1048576L).start() }