n = gets.to_i
arr = gets.chomp.split(' ').map(&:to_i)
min = arr.sum
i = 0
while i < n
  if (arr[0..i].sum - arr[(i+1)..(n-1)].sum).abs < min
    min = (arr[0..i].sum - arr[(i+1)..(n-1)].sum).abs
  end
  i += 1
end
puts min