var n=readLine()!.characters.split{$0==" "}.map{Int(String($0))!}
var arr=readLine()!.characters.split{$0==" "}.map{Int(String($0))!}

var di : [Int] = []
var sum = 0;

 var i = 0; 

for i in 0..<n[0]  {
    sum += arr[i]
}

var diff = 0;
var total = 0
var min = sum
var min_i = 0

i = 0
for i in 0..<n[0] {
  total += arr[i]
  sum -= arr[i]
  
  diff = sum - total 
  
  diff = diff < 0 ? -diff: diff 
  di.append( diff  )
  
  if( min > diff ) {
    min = diff
    min_i = i
  }

}

print( di[min_i] )