#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
unsigned long long pow(int, unsigned long long);
int /*<<< orphan*/ printf(char *, unsigned long long);
int /*<<< orphan*/ scanf(char *, ...);
int main() {
  int test = 0;
  unsigned long long length = 0, i = 0;
  unsigned long long answer = 0;
  unsigned long long element = 0;
  scanf("%d", &test);
  while (test != 0) {
    scanf("%llu", &length);
    for (i = 0; i < length; i++) {
      scanf("%llu", &element);
      answer = answer | element;
    }
    answer = answer * pow(2, length - 1);
    printf("%llu", answer);
    --test;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movq   $0x0,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
lea    0xe93(%rip),%rdi
lea    -0x8(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
cmpl   $0x0,-0x8(%rbp)
je     1220 <main+0xf0>
lea    0xe7a(%rip),%rdi
lea    -0x10(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
movq   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%rax
cmp    -0x10(%rbp),%rax
jae    11d9 <main+0xa9>
lea    0xe52(%rip),%rdi
lea    -0x28(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
mov    -0x20(%rbp),%rax
or     -0x28(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    119c <main+0x6c>
mov    -0x20(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rsi
sub    $0x1,%rsi
mov    $0x2,%edi
call   1050 <pow@plt>
mov    %rax,%rcx
mov    -0x30(%rbp),%rax
imul   %rcx,%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rsi
lea    0xdf6(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x8(%rbp)
jmp    1178 <main+0x48>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x20,%rsp
movl   $0x0,0xc(%rsp)
movq   $0x0,0x10(%rsp)
movq   $0x0,0x18(%rsp)
lea    0xea2(%rip),%rdi
lea    0xc(%rsp),%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
cmpl   $0x0,0xc(%rsp)
je     11f2 <main+0xc2>
lea    0xe87(%rip),%r12
lea    0x10(%rsp),%r14
lea    0x18(%rsp),%r15
xor    %r13d,%r13d
jmp    11b6 <main+0x86>
nopl   0x0(%rax,%rax,1)
xor    %esi,%esi
add    $0xffffffffffffffff,%rsi
mov    $0x2,%edi
call   1050 <pow@plt>
imul   %rax,%r13
mov    %r12,%rdi
mov    %r13,%rsi
call   1030 <printf@plt>
addl   $0xffffffff,0xc(%rsp)
je     11f2 <main+0xc2>
mov    %r12,%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
cmpq   $0x0,0x10(%rsp)
je     1190 <main+0x60>
xor    %ebx,%ebx
nopl   (%rax)
mov    %r12,%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
or     0x18(%rsp),%r13
add    $0x1,%rbx
mov    0x10(%rsp),%rsi
cmp    %rsi,%rbx
jb     11d0 <main+0xa0>
jmp    1192 <main+0x62>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@.str.1 = [5 x i8] c"%llu\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i64
%4 = alloca i64
%5 = alloca i64
%6 = alloca i64
store i32 0, i32* %1
store i32 0, i32* %2
store i64 0, i64* %3
store i64 0, i64* %4
store i64 0, i64* %5
store i64 0, i64* %6
%7 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
br label %8
8: ; preds = %25, %0
%9 = load i32, i32* %2
%10 = icmp ne i32 %9, 0
br i1 %10, label %11, label %35
11: ; preds = %8
%12 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i64* %3)
store i64 0, i64* %4
br label %13
13: ; preds = %22, %11
%14 = load i64, i64* %4
%15 = load i64, i64* %3
%16 = icmp ult i64 %14, %15
br i1 %16, label %17, label %25
17: ; preds = %13
%18 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i64* %6)
%19 = load i64, i64* %5
%20 = load i64, i64* %6
%21 = or i64 %19, %20
store i64 %21, i64* %5
br label %22
22: ; preds = %17
%23 = load i64, i64* %4
%24 = add i64 %23, 1
store i64 %24, i64* %4
br label %13
25: ; preds = %13
%26 = load i64, i64* %5
%27 = load i64, i64* %3
%28 = sub i64 %27, 1
%29 = call i64 @pow(i32 2, i64 %28)
%30 = mul i64 %26, %29
store i64 %30, i64* %5
%31 = load i64, i64* %5
%32 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i64 %31)
%33 = load i32, i32* %2
%34 = add nsw i32 %33, -1
store i32 %34, i32* %2
br label %8
35: ; preds = %8
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.1 = [5 x i8] c"%llu\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i64
%3 = alloca i64
%4 = bitcast i32* %1 to i8*
store i32 0, i32* %1
%5 = bitcast i64* %2 to i8*
store i64 0, i64* %2
%6 = bitcast i64* %3 to i8*
store i64 0, i64* %3
%7 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%8 = load i32, i32* %1
%9 = icmp eq i32 %8, 0
br i1 %9, label %34, label %10
10: ; preds = %0, %24
%11 = phi i64 [ %29, %24 ], [ 0, %0 ]
%12 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i64* %2)
%13 = load i64, i64* %2
%14 = icmp eq i64 %13, 0
br i1 %14, label %24, label %15
15: ; preds = %10, %15
%16 = phi i64 [ %20, %15 ], [ %11, %10 ]
%17 = phi i64 [ %21, %15 ], [ 0, %10 ]
%18 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i64* %3)
%19 = load i64, i64* %3
%20 = or i64 %19, %16
%21 = add nuw i64 %17, 1
%22 = load i64, i64* %2
%23 = icmp ult i64 %21, %22
br i1 %23, label %15, label %24
24: ; preds = %15, %10
%25 = phi i64 [ %11, %10 ], [ %20, %15 ]
%26 = phi i64 [ 0, %10 ], [ %22, %15 ]
%27 = add i64 %26, -1
%28 = call i64 @pow(i32 2, i64 %27)
%29 = mul i64 %28, %25
%30 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i64 %29)
%31 = load i32, i32* %1
%32 = add nsw i32 %31, -1
store i32 %32, i32* %1
%33 = icmp eq i32 %32, 0
br i1 %33, label %34, label %10
34: ; preds = %24, %0
ret i32 0
}