import std; int readInt() { int x; readf!" %d"(x); return x; } int[] readArray(int n) { auto a = new int[](n); return a.map!(i => readInt).array; } const long P = (1e9 + 7).to!long; void main() { int T = readInt; foreach(_; 0 .. T) { int n = readInt; auto a = readArray(n); writeln(a.fold!((a, b) => ((a + 1).to!long * (b + 1) - 1) % P)); } }