using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;
using System.IO;

namespace ContestTemplate
{
    #region interface class

    /// <summary>
    /// IO method interface
    /// </summary>
    public interface IInputOutput
    {
        /// <summary>
        /// read a single line from any stream
        /// </summary>
        /// <returns></returns>
        string ReadLine();

        /// <summary>
        /// write the data as a single line to any stream
        /// </summary>
        /// <param name="data"></param>
        void WriteLine(string data);
    }

    /// <summary>
    /// executable interface
    /// </summary>
    public interface IRunner
    {
        /// <summary>
        /// execute main process
        /// </summary>
        void Execute();
    }

    #endregion

    #region common class

    /// <summary>
    /// factory class of the main process runnger
    /// </summary>
    internal static class RunnerFactory
    {
        /// <summary>
        /// create executable main process runner
        /// </summary>
        /// <param name="isTest">test mode or one for submitting as a final code</param>
        /// <returns></returns>
        internal static IRunner Create(bool isTest)
        {
            if (isTest == false)
            {
                return new ConsoleInputOutputRunner();
            }
            else
            {
                return new TestRunner();
            }
        }
    }

    /// <summary>
    /// IO to/from console
    /// </summary>
    internal class ConsoleInputOutput : IInputOutput
    {
        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        string IInputOutput.ReadLine()
        {
            return Console.ReadLine();
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="data"></param>
        void IInputOutput.WriteLine(string data)
        {
            Console.WriteLine(data);
        }
    }

    /// <summary>
    /// IO to/from test data
    /// </summary>
    internal class TestInputOutput : IInputOutput, IDisposable
    {
        /// <summary>
        /// 
        /// </summary>
        private readonly TextReader inputDataStream;

        /// <summary>
        /// 
        /// </summary>
        private readonly StringBuilder outputDataStream;

        /// <summary>
        /// 
        /// </summary>
        private bool isDisposed = false;

        /// <summary>
        /// constructor
        /// </summary>
        /// <param name="input">test input data</param>
        internal TestInputOutput(string input)
        {
            this.inputDataStream = new StringReader(input);
            this.outputDataStream = new StringBuilder();
        }

        /// <summary>
        /// finalizer
        /// </summary>
        ~TestInputOutput()
        {
            this.Dispose(false);
            GC.SuppressFinalize(this);
        }

        /// <summary>
        /// 
        /// </summary>
        public void Dispose()
        {
            this.Dispose(true);
            GC.SuppressFinalize(this);
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="isDisposing"></param>
        protected virtual void Dispose(bool isDisposing)
        {
            if (this.isDisposed == true)
            {
                return;
            }

            if (isDisposing == true)
            {
                this.inputDataStream.Dispose();
            }
        }

        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        string IInputOutput.ReadLine()
        {
            return this.inputDataStream.ReadLine();
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="data"></param>
        void IInputOutput.WriteLine(string data)
        {
            this.outputDataStream.Append(data + "\n");
        }

        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        internal string ObtainOutputData()
        {
            return this.outputDataStream.ToString();
        }
    }

    /// <summary>
    /// console input/output executable runner 
    /// for submitting as a final code
    /// </summary>
    internal class ConsoleInputOutputRunner : IRunner
    {
        /// <summary>
        /// execute main proces using console input/ ouput
        /// </summary>
        public void Execute()
        {
            Program.DoMainProcess(new ConsoleInputOutput());
        }
    }

    /// <summary>
    /// unit test executable runner
    /// </summary>
    internal class TestRunner : IRunner
    {
        /// <summary>
        /// execute all test cases
        /// </summary>
        public void Execute()
        {
            foreach (var inputAndExpectedResult in TestDataForLocal.ObtainTestInputAndExpectedResultMap())
            {
                var input = inputAndExpectedResult.Key;
                var expectedResult = inputAndExpectedResult.Value;

                Console.WriteLine(string.Format("TEST:: input=[\n{0}\n], \nexpectedOutput=[{1}]", input, expectedResult));

                using (var inputOutput = new TestInputOutput(input))
                {
                    Program.DoMainProcess(inputOutput);
                    var result = inputOutput.ObtainOutputData();

                    Console.WriteLine(string.Format("TEST:: result=[\n{0}], \njudge::[{1}]", result, result == expectedResult));
                    Console.WriteLine(string.Empty);
                }
            }

            // just to wait (to check the result)
            Console.ReadKey();
        }
    }

    #endregion

    #region test data

    /// <summary>
    /// unit test data
    /// </summary>
    internal static class TestDataForLocal
    {
        /// <summary>
        /// get the mapped data of input and expected result string
        /// **EDIT THIS DATA TO CHANGE TEST CASES** 
        /// </summary>
        /// <returns></returns>
        internal static Dictionary<string, string> ObtainTestInputAndExpectedResultMap()
        {
            return new Dictionary<string, string>()
            {
                {"3\n1 3 4", "0\n"},
                {"4\n1 3 1 1", "2\n"},
                {"8\n27 23 76 2 3 5 62 52", "2\n"},
            };
        }
    }

    #endregion

    class Program
    {
        static void Main(string[] args)
        {
            const bool isTest = false;
            RunnerFactory.Create(isTest).Execute();
        }

        /// <summary>
        /// main algorithm of the question
        /// </summary>
        /// <param name="inputOuput"></param>
        internal static void DoMainProcess(IInputOutput inputOuput)
        {
            var line1 = inputOuput.ReadLine();

            var n = int.Parse(line1);

            var line2 = inputOuput.ReadLine();

            var lineArray = line2.Split(' ');

            var intArray = lineArray.Select(x => int.Parse(x));

            int min = int.MaxValue;

            for (int i = 0; i < intArray.Count() - 1; i ++)
            {
                var leftArray = intArray.Take(i + 1);
                var rightArray = intArray.Skip(i + 1).Take(intArray.Count() - i - 1);

                var leftSum = leftArray.Sum();
                var rightSum = rightArray.Sum();

                var abs = Math.Abs(leftSum - rightSum);

                if (min > abs)
                {
                    min = abs;
                }

                if (min == 0)
                {
                    break;
                }
            }

            inputOuput.WriteLine(string.Format("{0}", min));
            return;
        }

    }

}

Measured memory_bytes: 13396