import Data.List.Split
import Data.Maybe
import qualified Data.ByteString.Char8 as B
import qualified Data.IntSet as IS
main=mapM_(print.solve).chunksOf 2.map(map(fst.fromJust.B.readInt).B.words).B.lines=<<B.getContents
solve[[n],as]=minimum$map(\v->t-2*min(t-v)v)$IS.toList$foldr f IS.empty$tail as
  where t=foldr(+)0 as
f a s=IS.insert a$IS.foldr(\v->IS.insert(a+v))s s