use std::io::{Read, Write}; struct Scanner { bytes: std::io::Bytes, buf: Vec } impl Scanner { fn new(r: R) -> Scanner { Scanner { bytes: r.bytes(), buf: Vec::new() } } fn next(&mut self) -> &str { self.buf = { self.bytes.by_ref().map(|b| b.unwrap()) .skip_while(|b| b.is_ascii_whitespace()) .take_while(|b| !b.is_ascii_whitespace()) .collect::>() }; unsafe { std::str::from_utf8_unchecked(&self.buf) } } } macro_rules! scan { ($sc:expr, [$t:tt; $n:expr]) => ( (0..$n).map(|_| scan!($sc, $t)).collect::>() ); ($sc:expr, ($($t:tt),*)) => (($(scan!($sc, $t)),*)); ($sc:expr, Usize1) => (scan!($sc, usize) - 1); ($sc:expr, Bytes) => ($sc.next().bytes().collect::>()); ($sc:expr, Chars) => ($sc.next().chars().collect::>()); ($sc:expr, $t:ty) => ($sc.next().parse::<$t>().unwrap()); } fn run(mut sc: Scanner, mut wr: W) { const MOD: i64 = 1_000_000_007; for _ in 0..scan!(sc, usize) { let n = scan!(sc, usize); let a = scan!(sc, [i64; n]); writeln!( wr, "{}", a.into_iter().fold(1, |acc, val| acc * (val + 1) % MOD) - 1 ).ok(); } } fn main() { let (stdin, stdout) = (std::io::stdin(), std::io::stdout()); let sc = Scanner::new(std::io::BufReader::new(stdin.lock())); let wr = std::io::BufWriter::new(stdout.lock()); run(sc, wr); } /* a b c (ab + a + b) c abc + ac + bc + ab + a + b + c */