import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS

main = do
  n <- getLine
  ws <- getIntList
  print $ func 1 (sum ws) ws
  
func p min ws 
  | temp > min = min
  | otherwise = func (p+1) temp ws
  
  where 
    (ls, rs) = splitAt p ws
    lSum = sum ls
    rSum = sum rs 
    temp = abs (lSum - rSum)

readInt = fst . fromJust . BS.readInteger
readIntList = map readInt . BS.words
getIntList = readIntList <$> BS.getLine
