Johnny and the Beanstalk - getting TLE

Hello Chefs,

Will you please help on the following code, it is giving TLE
Problem - MARCHA2 Problem - CodeChef :

import sys
for _ in range(int(sys.stdin.readline())):
    k = int(sys.stdin.readline())
    a = list(map(int,sys.stdin.readline().split()))
    stem = 1
    f = True
    for i in range(k):
        if a[i]>stem:
            print('No')
            break
        stem = 2*(stem-a[i])
    else:
        if stem==0:
            print('Yes')
        else:
            print('No')