#include #include #include #include #include #include #include #define mod 1000000007ll using namespace std; long long pw[100001]; int a[100001]; map m; int main() { pw[0] = 1ll; for(int i=1;i<=100000;i++) pw[i] = (pw[i-1] + pw[i-1])%mod; int n, T; scanf("%d", &T); while(T--) { m.clear(); scanf("%d" , &n); for(int i=1;i<=n;i++) scanf("%d", &a[i]); long long sum = 0, ans = 0; for(int i=1;i<=n;i++) { sum = (ans + (pw[i-1]*a[i])%mod)%mod; sum = (sum - (m[a[i]]*a[i])%mod)%mod; // sum = (sum + sum)%mod; if(sum < 0) sum += mod; m[a[i]] += (pw[i-1])%mod; if(m[a[i]] > mod) m[a[i]] %= mod; // cout << sum << endl; ans = (ans + sum)%mod; //cout << ans << endl; } cout << ans << endl; } }