Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
array = input().split(' ')

def getSum(s, e):
    sum = 0
    for i in range(s, e):
        sum = sum + int(array[i])
    return sum

prev = 0
for i in range(0,n-1):
    diff = abs(getSum(0, i+1) - getSum(i+1, n))
    if(i == 0):
        prev = diff
    else:
        if diff < prev:
            prev = diff
print(prev)





Fixed submission:
n = int(input())
array = list(map(int,input().split(' ')))

left= array[0]
right = sum(array) - left

prev = 0
for i in range(0,n-1):
    diff = abs(left - right)
    left = left + array[i+1]
    right = right - array[i+1]

    if(i == 0):
        prev = diff
    else:
        if diff < prev:
            prev = diff
print(prev)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
array = input().split(' ')

def getSum(s, e):
    sum = 0
    for i in range(s, e):
        sum = sum + int(array[i])
    return sum

prev = 0
for i in range(0,n-1):
    diff = abs(getSum(0, i+1) - getSum(i+1, n))
    if(i == 0):
        prev = diff
    else:
        if diff < prev:
            prev = diff
print(prev)





Fixed submission:
n = int(input())
array = list(map(int,input().split(' ')))

left= array[0]
right = sum(array) - left

prev = 0
for i in range(0,n-1):
    diff = abs(left - right)
    left = left + array[i+1]
    right = right - array[i+1]

    if(i == 0):
        prev = diff
    else:
        if diff < prev:
            prev = diff
print(prev)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
array = list(map(int,input().split(' ')))

def getSum(s, e):
    sum = 0
    for i in range(s, e):
        sum = sum + array[i]
    return sum

prev = 0
for i in range(0,n-1):
    diff = abs(getSum(0, i+1) - getSum(i+1, n))
    if(i == 0):
        prev = diff
    else:
        if diff < prev:
            prev = diff
print(prev)





Fixed submission:
n = int(input())
array = list(map(int,input().split(' ')))

left= array[0]
right = sum(array) - left

prev = 0
for i in range(0,n-1):
    diff = abs(left - right)
    left = left + array[i+1]
    right = right - array[i+1]

    if(i == 0):
        prev = diff
    else:
        if diff < prev:
            prev = diff
print(prev)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
list = list(map(int,input().split(' ')))

def getSum(s, e):
    sum = 0
    for i in range(s, e):
        sum = sum + list[i]
    return sum

prev = 0
for i in range(0,n-1):
    diff = abs(getSum(0, i+1) - getSum(i+1, n))
    if(i == 0):
        prev = diff
    else:
        if diff < prev:
            prev = diff
print(prev)



Fixed submission:
n = int(input())
array = list(map(int,input().split(' ')))

left= array[0]
right = sum(array) - left

prev = 0
for i in range(0,n-1):
    diff = abs(left - right)
    left = left + array[i+1]
    right = right - array[i+1]

    if(i == 0):
        prev = diff
    else:
        if diff < prev:
            prev = diff
print(prev)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
list = list(map(int,input().split(' ')))

def getSum(s, e):
    sum = 0
    for i in range(s, e):
        sum = sum + list[i]
    return sum

prev = 0
for i in range(0,n-1):
    diff = abs(getSum(0, i+1) - getSum(i+1, n))
    if(i == 0):
        prev = diff
    else:
        if diff < prev:
            prev = diff
print(prev)


Fixed submission:
n = int(input())
array = list(map(int,input().split(' ')))

left= array[0]
right = sum(array) - left

prev = 0
for i in range(0,n-1):
    diff = abs(left - right)
    left = left + array[i+1]
    right = right - array[i+1]

    if(i == 0):
        prev = diff
    else:
        if diff < prev:
            prev = diff
print(prev)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
list = list(map(int,input().split(' ')))

def getSum(list):
    sum = 0
    for i in list:
      sum = sum + i
    return sum  

prev = 0
for i in range(0,n-1):
    left = list[:i+1]
    right = list[i+1:]
    diff = abs(getSum(left) - getSum(right))
    if(i == 0):
        prev = diff
    else:
        if diff < prev:
            prev = diff
    if diff == 0:
        print(prev)
        exit()
print(prev)


Fixed submission:
n = int(input())
array = list(map(int,input().split(' ')))

left= array[0]
right = sum(array) - left

prev = 0
for i in range(0,n-1):
    diff = abs(left - right)
    left = left + array[i+1]
    right = right - array[i+1]

    if(i == 0):
        prev = diff
    else:
        if diff < prev:
            prev = diff
print(prev)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
list = list(map(int,input().split(' ')))

prev = 0
for i in range(0,n-1):
    left = list[:i+1]
    right = list[i+1:]
    diff = abs(sum(left) - sum(right))
    if(i == 0):
        prev = diff
    else:
        if diff < prev:
            prev = diff
    if diff == 0:
        print(prev)
        exit()
print(prev)


Fixed submission:
n = int(input())
array = list(map(int,input().split(' ')))

left= array[0]
right = sum(array) - left

prev = 0
for i in range(0,n-1):
    diff = abs(left - right)
    left = left + array[i+1]
    right = right - array[i+1]

    if(i == 0):
        prev = diff
    else:
        if diff < prev:
            prev = diff
print(prev)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
list = list(map(int,input().split(' ')))

prev = 0
for i in range(0,n-1):
    left = list[:i+1]
    right = list[i+1:]
    diff = abs(sum(left) - sum(right))
    if(i == 0):
        prev = diff
    else:
        if diff < prev:
            prev = diff
print(prev)


Fixed submission:
n = int(input())
array = list(map(int,input().split(' ')))

left= array[0]
right = sum(array) - left

prev = 0
for i in range(0,n-1):
    diff = abs(left - right)
    left = left + array[i+1]
    right = right - array[i+1]

    if(i == 0):
        prev = diff
    else:
        if diff < prev:
            prev = diff
print(prev)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
list = list(map(int,input().split(' ')))

def getTargetIndex():
    prev = 0
    for i in range(0,n-1):
        left = 0
        right = 0
        left = list[:i+1]
        right = list[i+1:]
        diff = abs(sum(left)- sum(right))
        if(i == 0):
            prev = diff
        else:
            if diff < prev:
                prev = diff
    print(prev)


getTargetIndex()


Fixed submission:
n = int(input())
array = list(map(int,input().split(' ')))

left= array[0]
right = sum(array) - left

prev = 0
for i in range(0,n-1):
    diff = abs(left - right)
    left = left + array[i+1]
    right = right - array[i+1]

    if(i == 0):
        prev = diff
    else:
        if diff < prev:
            prev = diff
print(prev)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
list = list(map(int,input().split(' ')))

def getTargetIndex():
    target = 0
    prev =  0
    for i in range(0,n-1):
        left = 0
        right = 0
        left = list[:i+1]
        right = list[i+1:]
        diff = abs(sum(left)- sum(right))
        if(i == 0):
            target = i
            prev = diff
        else:
            if diff < prev:
                target = i
                prev = diff
    return target + 1

div = getTargetIndex()
left = list[:div]
right = list[div:]
print(abs(sum(left) -sum(right)) )


Fixed submission:
n = int(input())
array = list(map(int,input().split(' ')))

left= array[0]
right = sum(array) - left

prev = 0
for i in range(0,n-1):
    diff = abs(left - right)
    left = left + array[i+1]
    right = right - array[i+1]

    if(i == 0):
        prev = diff
    else:
        if diff < prev:
            prev = diff
print(prev)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
list = list(map(int,input().split(' ')))

def getTargetIndex():
    diffList = []
    for i in range(0,n-1):
        left = 0
        right = 0
        left = list[:i+1]
        right = list[i+1:]
        diffList.append(abs(sum(left)- sum(right)))
    return diffList.index(min(diffList)) + 1

div = getTargetIndex()
left = list[:div]
right = list[div:]
print(abs(sum(left) -sum(right)) )


Fixed submission:
n = int(input())
array = list(map(int,input().split(' ')))

left= array[0]
right = sum(array) - left

prev = 0
for i in range(0,n-1):
    diff = abs(left - right)
    left = left + array[i+1]
    right = right - array[i+1]

    if(i == 0):
        prev = diff
    else:
        if diff < prev:
            prev = diff
print(prev)

Buggy python submission (verdict: Runtime Error):
n = int(input())
list = list(map(int,input().split(' ')))

def getTargetIndex():
    diffList = []
    for i in range(0,n-1):
        left = 0
        right = 0
        left = list[:i+1]
        right = list[i+1:]
        diffList.append(abs(sum(left)- sum(right)))  
    return list.index(min(diffList))

div = getTargetIndex()
left = list[:div]
right = list[div:]
print(abs(sum(left) -sum(right)) )

Fixed submission:
n = int(input())
array = list(map(int,input().split(' ')))

left= array[0]
right = sum(array) - left

prev = 0
for i in range(0,n-1):
    diff = abs(left - right)
    left = left + array[i+1]
    right = right - array[i+1]

    if(i == 0):
        prev = diff
    else:
        if diff < prev:
            prev = diff
print(prev)

Buggy python submission (verdict: Time Limit Exceeded):

n = int(input())
list = list(map(int,input().split(' ')))


def reduceNum(index):
    list[index] = list[index] - 1

def getTargetIndex():
    diffList = []
    for i in range(0,n-1):
        left = 0
        right = 0
        left = list[:i+1]
        right = list[i+1:]
        diffList.append(abs(sum(left)- sum(right)))  
    m = min(diffList)
    for i in range(len(diffList)):
        if m == diffList[i]:
            return i+1

div = getTargetIndex()
left = list[:div]
right = list[div:]
print(abs(sum(left) -sum(right)) )

Fixed submission:
n = int(input())
array = list(map(int,input().split(' ')))

left= array[0]
right = sum(array) - left

prev = 0
for i in range(0,n-1):
    diff = abs(left - right)
    left = left + array[i+1]
    right = right - array[i+1]

    if(i == 0):
        prev = diff
    else:
        if diff < prev:
            prev = diff
print(prev)