import numpy
import math
n = int(input())
w = list(map(int, input().split()))

sum_w = sum(w)
sum_w = sum_w / 2

res = numpy.cumsum(w)

diff = [2.0 * math.fabs(res[i] - sum_w) for i in range(n)]
print(int(min(diff))) import numpy numpy import math math n = int(input()) n int(input()) int input() input w = list(map(int, input().split())) w list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split sum_w = sum(w) sum_w sum(w) sum w sum_w = sum_w / 2 sum_w sum_w / 2 sum_w 2 res = numpy.cumsum(w) res numpy.cumsum(w) numpy.cumsum numpy cumsum w 2.0 * math.fabs(res[i] - sum_w) for i in range(n) for i in range(n) i range(n) range n for i in range(n) 2.0 * math.fabs(res[i] - sum_w) 2.0 math.fabs(res[i] - sum_w) math.fabs math fabs res[i] - sum_w res[i] res i sum_w diff = [2.0 * math.fabs(res[i] - sum_w) for i in range(n)] diff [2.0 * math.fabs(res[i] - sum_w) for i in range(n)] print(int(min(diff))) print int(min(diff)) int min(diff) min diff sum_w = sum_w / 2 sum_w / 2 sum_w diff = [2.0 * math.fabs(res[i] - sum_w) for i in range(n)] [2.0 * math.fabs(res[i] - sum_w) for i in range(n)] diff res = numpy.cumsum(w) numpy.cumsum(w) res sum_w = sum(w) sum(w) sum_w n = int(input()) int(input()) n w = list(map(int, input().split())) list(map(int, input().split())) w
import numpy
import math
n = int(input())
w = list(map(int, input().split()))

sum_w = sum(w)
sum_w = sum_w / 2

res = numpy.cumsum(w)

diff = [2.0 * math.fabs(res[i] - sum_w) for i in range(n)]
print(int(min(diff)))