import java.util.Scanner; public class Main { public static void main(String[] args) throws Exception { Scanner sc = new Scanner(System.in); int t = sc.nextInt(); int mod = 1000000007; for (int i = 0; i < t; i++) { int n = sc.nextInt(); int[] a = new int[n]; for (int j = 0; j < n; j++) { a[j] = sc.nextInt(); } long ans = a[0]; for (int j = 1; j < n; j++) { ans = ans + a[j] + ans * a[j]; ans %= mod; } System.out.println(ans); } sc.close(); } }