Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
temparr = input()
temparr = temparr.split()
flag = 0 

arr = []
first = 0 
totallen = 0 
for i in  temparr:
    if first == 0 :
        totallen += len(i)
        first = 1 
    else:
        totallen += len(i) - 1 
    if totallen > 19:
        flag = 2
        break
    if "0" in temparr:
        flag = 1 
        break 
    if i == "1" :
        continue
    arr.append(int(i))
if flag == 2:
    print("-1")
elif flag == 1 :
    print("0")
else:
    ans = 1
    arr = sorted(arr)
    arr = arr[::-1]
    for i in arr:
        ans *= i 
        if ans > 1000000000000000000:
            flag = 1 
            break 
    if flag == 0 :
        print(ans)
    else:
        print(-1)
        
        
        


Fixed submission:
n = int(input())
temparr = input()
temparr = temparr.split()
flag = 0 

arr = []
first = 0 
totallen = 0 
arr =[]
arr1 = []
for i in temparr:
    arr1.append(int(i))
arr1 = sorted(arr1)
for i in arr1:
    if i == 0 :
        flag = 1 
        break 
    if i == 1 :
        continue 
    
    if first == 0 :
        totallen += len(str(i))
        first = 1 
    else:
        totallen += len(str(i)) - 1 
    if totallen > 19:
        flag = 2
        break
    arr.append(i)
    
    
if flag == 2:
    print("-1")
elif flag == 1 :
    print("0")
else:
    ans = 1
    arr = sorted(arr)
    arr = arr[::-1]
    for i in arr:
        ans *= i 
        if ans > 1000000000000000000:
            flag = 1 
            break 
    if flag == 0 :
        print(ans)
    else:
        print(-1)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
temparr = input()
temparr = temparr.split()
flag = 0 

arr = []
first = 0 
totallen = 0 
for i in  temparr:
    if first == 0 :
        totallen += len(i)
        first = 1 
    else:
        totallen += len(i) - 1 
    if totallen > 19:
        flag = 2
        break
    if "0" in temparr:
        flag = 1 
        break 

    arr.append(int(i))
if flag == 2:
    print("-1")
elif flag == 1 :
    print("0")
else:
    ans = 1
    arr = sorted(arr)
    arr = arr[::-1]
    for i in arr:
        ans *= i 
        if ans > 1000000000000000000:
            flag = 1 
            break 
    if flag == 0 :
        print(ans)
    else:
        print(-1)
        
        
        

Fixed submission:
n = int(input())
temparr = input()
temparr = temparr.split()
flag = 0 

arr = []
first = 0 
totallen = 0 
arr =[]
arr1 = []
for i in temparr:
    arr1.append(int(i))
arr1 = sorted(arr1)
for i in arr1:
    if i == 0 :
        flag = 1 
        break 
    if i == 1 :
        continue 
    
    if first == 0 :
        totallen += len(str(i))
        first = 1 
    else:
        totallen += len(str(i)) - 1 
    if totallen > 19:
        flag = 2
        break
    arr.append(i)
    
    
if flag == 2:
    print("-1")
elif flag == 1 :
    print("0")
else:
    ans = 1
    arr = sorted(arr)
    arr = arr[::-1]
    for i in arr:
        ans *= i 
        if ans > 1000000000000000000:
            flag = 1 
            break 
    if flag == 0 :
        print(ans)
    else:
        print(-1)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
temparr = input()
temparr = temparr.split()
flag = 0 

arr = []
first = 0 
totallen = 0 
for i in  temparr:
    if first == 0 :
        totallen += len(i)
        first = 1 
    else:
        totallen += len(i) - 1 
    if totallen > 19:
        flag = 2
        break
    if "0" in temparr:
        flag = 1 
        break 

    arr.append(int(i))
if flag == 2:
    print("-1")
elif flag == 1 :
    print("0")
else:
    ans = 1
    for i in arr:
        ans *= i 
        if ans > 1000000000000000000:
            flag = 1 
            break 
    if flag == 0 :
        print(ans)
    else:
        print(-1)
        
        
        

Fixed submission:
n = int(input())
temparr = input()
temparr = temparr.split()
flag = 0 

arr = []
first = 0 
totallen = 0 
arr =[]
arr1 = []
for i in temparr:
    arr1.append(int(i))
arr1 = sorted(arr1)
for i in arr1:
    if i == 0 :
        flag = 1 
        break 
    if i == 1 :
        continue 
    
    if first == 0 :
        totallen += len(str(i))
        first = 1 
    else:
        totallen += len(str(i)) - 1 
    if totallen > 19:
        flag = 2
        break
    arr.append(i)
    
    
if flag == 2:
    print("-1")
elif flag == 1 :
    print("0")
else:
    ans = 1
    arr = sorted(arr)
    arr = arr[::-1]
    for i in arr:
        ans *= i 
        if ans > 1000000000000000000:
            flag = 1 
            break 
    if flag == 0 :
        print(ans)
    else:
        print(-1)