using System;
using System.Text;
using System.Collections.Generic;

namespace ForAcm
{
	class MainClass
	{
		public static void Main (string[] args)
		{
//			string t = Console.ReadLine ();
//			int it = int.Parse (t);
			Solve solve = new Solve ();
			solve.init ();
//			int i = 0;
//			while (it > 0) {
//				it--;
//				i++;
				solve.doit ();
				//solve.output (i);
//			}
		}
	}

	class Solve{
		private int  ans;
		private List<int> a = new List<int>();
		public void init(){
			a.Clear ();
			string s = Console.ReadLine ();
			int n = int.Parse (s);
			s = Console.ReadLine ();
			string[] ss = s.Split (' ');
			for (int i = 0; i < n / 2; i++) {
				a.Add(int.Parse (ss[i]) - 1);
			}
			a.Sort ();
			int s1 = 0;
			int s2 = 0;
			for (int i = 0; i < n / 2; i++) {
				s1 += Math.Abs( a [i] - i * 2);
				s2 += Math.Abs( a[i] - i* 2 - 1);
			}
			if (s1 < s2)
				Console.WriteLine (s1);
			else
				Console.WriteLine (s2);
		}
		public void doit(){
		}

		/*public void output(int i){
			Console.WriteLine (string.Format ("Case #{0}: {1}", i, ans));
		}*/
	}
}

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

namespace CodeforcesTemplate
{

    public static class Permutation
    {
        private static bool Next(ref int[] arr)
        {
            int k, j, l;
            for (j = arr.Length - 2; (j >= 0) && (arr[j] >= arr[j + 1]); j--) { }
            if (j == -1)
            {
                arr = arr.OrderBy(c => c).ToArray();
                return false;
            }
            for (l = arr.Length - 1; (arr[j] >= arr[l]) && (l >= 0); l--) { }
            var tmp = arr[j];
            arr[j] = arr[l];
            arr[l] = tmp;
            for (k = j + 1, l = arr.Length - 1; k < l; k++, l--)
            {
                tmp = arr[k];
                arr[k] = arr[l];
                arr[l] = tmp;
            }
            return true;
        }
        public static IEnumerable<int[]> AllPermutations(int[] arr)
        {
            do yield return arr;
            while (Next(ref arr));
        }
    }

    class Program
    {
        private const string FILENAME = "distance4";

        private const string INPUT = FILENAME + ".in";

        private const string OUTPUT = FILENAME + ".out";

        private static Stopwatch _stopwatch = new Stopwatch();

        private static StreamReader _reader = null;
        private static StreamWriter _writer = null;

        private static string[] _curLine;
        private static int _curTokenIdx;

        private static char[] _whiteSpaces = new char[] { ' ', '\t', '\r', '\n' };

        static void main()
        {
            Console.ReadLine();

            string s = Console.ReadLine();

            List<char> arr = s.ToCharArray().ToList();

            arr.Sort();

            string res = "";

            int count = 0;

            while (res.Length != s.Length)
            {
                if (count > arr.Count - 1)
                {
                    count = 0;
                }

                if (res.Length == 0)
                {
                    res += arr[count];
                    arr.Remove(arr[count]);
                }

                else
                {
                    if (!res[res.Length - 1].Equals(arr[count]))
                    {
                        res += arr[count];

                        arr.Remove(arr[count]);

                        count = 0;
                    }
                }

                count++;
            }

            for (int i = 1; i < res.Length; i++)
            {
                if (res[i - 1].Equals(res[i]))
                {
                    Console.WriteLine("IMPOSSIBLE");
                    // Console.ReadKey();
                    return;
                }
            }

            Console.WriteLine(res);

        }

        private static int Nod(decimal n, decimal d)
        {
            n = Math.Abs(n);
            d = Math.Abs(d);
            while (d != 0 && n != 0)
            {
                if (n % d > 0)
                {
                    var temp = n;
                    n = d;
                    d = temp % d;
                }
                else break;
            }
            if (d != 0 && n != 0) return (int)d;
            return 0;
        }

        static int Count(string source, string key)
        {

            List<int> indices = new List<int>();

            int index = source.IndexOf(key, 0);

            while (index > -1)
            {
                indices.Add(index);
                index = source.IndexOf(key, index + key.Length);
            }

            return indices.Count();
        }

        private static string Reverse(string s)
        {
            string s2 = "";

            for (int i = s.Length - 1; i >= 0; i--)
            {
                s2 += s[i];
            }

            return s2;
        }

        private static void RunTimer()
        {
#if (DEBUG)

            _stopwatch.Start();

#endif
        }

        private static void Main(string[] args)
        {

#if (DEBUG)
            double before = GC.GetTotalMemory(false);
#endif

            StringBuilder builder = new StringBuilder();

            int n = int.Parse(Console.ReadLine());
            string[] locationData = Console.ReadLine().Split();

            int[] locations = new int[n / 2];
            int bMoves = 0;
            int wMoves = 0;
            for (int i = 0; i < locationData.Length; i++)
            {
                int current = int.Parse(locationData[i]);
                locations[i] = current;
            }

            Array.Sort(locations);
            for (int i = 0; i < locations.Length; i++)
            {
                int current = locations[i];
                int bTarget = (i * 2) + 1;
                int wTarget = (i * 2) + 2;
                bMoves += Math.Abs(bTarget - current);
                wMoves += Math.Abs(wTarget - current);
            }

            builder.Append((int)Math.Min(bMoves, wMoves) + "\n");

           Console.WriteLine(builder);

#if (DEBUG)
            _stopwatch.Stop();

            double after = GC.GetTotalMemory(false);

            double consumedInMegabytes = (after - before) / (1024 * 1024);

            Console.WriteLine($"Time elapsed: {_stopwatch.Elapsed}");

            Console.WriteLine($"Consumed memory (MB): {consumedInMegabytes}");

            Console.ReadKey();
#endif

        }

        private static int CountLeadZeros(string source)
        {
            int countZero = 0;

            for (int i = source.Length - 1; i >= 0; i--)
            {
                if (source[i] == '0')
                {
                    countZero++;
                }

                else
                {
                    break;
                }

            }

            return countZero;
        }

        private static int[] CopyOfRange(int[] src, int start, int end)
        {
            int len = end - start;
            int[] dest = new int[len];
            Array.Copy(src, start, dest, 0, len);
            return dest;
        }

        private static int BFS(int start, int end, int[,] arr)
        {
            Queue<KeyValuePair<int, int>> queue = new Queue<KeyValuePair<int, int>>();
            List<bool> visited = new List<bool>();
            for (int i = 0; i < arr.GetLength(0); i++)
            {
                visited.Add(false);
            }

            queue.Enqueue(new KeyValuePair<int, int>(start, 0));
            KeyValuePair<int, int> node;
            int level = 0;
            bool flag = false;

            while (queue.Count != 0)
            {
                node = queue.Dequeue();
                if (node.Key == end)
                {
                    return node.Value;
                }
                flag = false;
                for (int i = 0; i < arr.GetLength(0); i++)
                {

                    if (arr[node.Key, i] == 1)
                    {
                        if (visited[i] == false)
                        {
                            if (!flag)
                            {
                                level = node.Value + 1;
                                flag = true;
                            }
                            queue.Enqueue(new KeyValuePair<int, int>(i, level));
                            visited[i] = true;
                        }
                    }
                }

            }
            return 0;

        }

        private static void Write(string source)
        {
            File.WriteAllText(OUTPUT, source);
        }

        private static string ReadString()
        {
            return File.ReadAllText(INPUT);
        }

        private static void WriteStringArray(string[] source)
        {
            File.WriteAllLines(OUTPUT, source);
        }

        private static string[] ReadStringArray()
        {
            return File.ReadAllLines(INPUT);
        }

        private static int[] GetIntArray()
        {
            return ReadString().Split(' ').Select(int.Parse).ToArray();
        }

        private static double[] GetDoubleArray()
        {
            return ReadString().Split(' ').Select(double.Parse).ToArray();
        }

        private static int[,] ReadINT2XArray(List<string> lines)
        {
            int[,] arr = new int[lines.Count, lines.Count];

            for (int i = 0; i < lines.Count; i++)
            {
                int[] row = lines[i].Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Select(int.Parse).ToArray();

                for (int j = 0; j < lines.Count; j++)
                {
                    arr[i, j] = row[j];
                }
            }

            return arr;
        }

    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Numerics;

namespace Kattis
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            string[] s = Console.ReadLine().Split();

            List<int> p = new List<int>();

            for (int i = 0; i < s.Length; i++)
            {
                p.Add(int.Parse(s[i]) - 1);
            }

            p.Sort();

            int aw = 0;
            int ab = 0;
            int cb = 0;
            int cw = 1;

            for (int i = 0; i < p.Count(); i++)
            {
                aw += Math.Abs(p[i] - cw);
                ab += Math.Abs(p[i] - cb);
                cb += 2;
                cw += 2;
            }
            Console.WriteLine(Math.Min(aw, ab));
        }
    }
}

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

namespace Practice
{
    public class Program
    {
        public static void Main()
        {
            ConsoleReader r = new ConsoleReader();
            BufferedStream w = new BufferedStream(Console.OpenStandardOutput());
            Solve(r, w);
            //Console.ReadKey();
        }

        public static void Solve(ConsoleReader reader, BufferedStream writer)
        {
            A(reader, writer);
        }
        public static void C()
        {

        }

        public static void B(ConsoleReader reader, BufferedStream writer)
        {
        }
        public static void A(ConsoleReader reader, BufferedStream writer)
        {
            int n = reader.ReadInt()/2;
            int[] a = new int[n];
            reader.ReadArray(a, n);

            Array.Sort(a);
            int bMoves = 0, wMoves = 0;
            for (int i =0; i<n; i++)
            {
                bMoves += Math.Abs(2*i + 1 - a[i]);
                wMoves += Math.Abs(2*i + 2 - a[i]);
            }

            Console.WriteLine(Math.Min(bMoves, wMoves));
        }
    }

    public class ConsoleReader
    {
        private String[] data;
        private int wordIndex = 0;

        private void ReadLineIfNeeded()
        {
            while (data == null || wordIndex >= data.Length)
            {
                wordIndex = 0;
                data = Console.ReadLine().Trim().Split();
            }
        }
        public int ReadInt()
        {
            ReadLineIfNeeded();
            return int.Parse(data[wordIndex++]);
        }

        public void ReadArray(int[] a, int n)
        {
            for (int i = 0; i < n; i++)
            {
                a[i] = ReadInt();
            }
        }

        public string ReadString()
        {
            ReadLineIfNeeded();
            return data[wordIndex++];
        }

        //ReadLine()

    }

}

using System;
using System.Linq;

namespace _985A
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int zoma = n / 2, oddCount=0,evenCount=0;
            int[] posArray = new int[zoma];
            var inputs = Console.ReadLine().Split().Select(int.Parse);
            posArray = inputs.ToArray();
            Array.Sort(posArray);
            for (int i=n, j = zoma-1; i > 0; i-=2,j--)
                if (posArray[j] != i) evenCount+= Math.Abs(i - posArray[j]);
            for (int i = n-1, j = zoma - 1; i > 0; i -= 2, j--)
                if (posArray[j] != i)  oddCount+= Math.Abs(i - posArray[j]);
            Console.WriteLine(evenCount < oddCount ? evenCount : oddCount);
        }
    }
}

using System;
using System.Linq;

namespace A
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int[] positions = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();

            n /= 2;
            Array.Sort(positions);

            int ans = int.MaxValue;
            for (int x = 1; x <= 2; x++)
            {
                int cnt = 0;
                for (int i = 0; i < n; i++)
                {
                    int p = positions[i];
                    int q = x + i * 2;
                    cnt += Math.Abs(p - q);
                }
                ans = Math.Min(ans, cnt);
            }

            Console.WriteLine($"{ans}");
        }
    }
}

using System;

namespace CF_985_A
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = Convert.ToInt32(Console.ReadLine());
            n = n / 2;
            int[] a = new int[n];
            string[] s = Console.ReadLine().Split();
            for (int i = 0; i < n; i++)
            {
                a[i] = Convert.ToInt32(s[i]);
            }
            Array.Sort(a);
            int nb = CountMoves(n, a, 1);
            int nw = CountMoves(n, a, 2);
            Console.WriteLine(Math.Min(nb, nw));
        }

        private static int CountMoves(int n, int[] a, int first)
        {
            int cnt = 0;
            for (int i = 0; i < n; i++)
            {
                cnt += Math.Abs(i*2+first - a[i]);
            }
            return cnt;
        }
    }
}

using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;
using static System.Diagnostics.Debug;

namespace QTREE3 {
    public class Program {
        public class Reader {
            private TextReader reader;
            private Queue<string> tokens;

            public Reader(Stream s) {
                reader = new StreamReader(s);
                tokens = new Queue<string>();
            }

            public Reader(string file) {
                reader = new StreamReader(file);
                tokens = new Queue<string>();
            }

            public string ReadLine() { return reader.ReadLine(); }

            public string ReadToken() {
                while (tokens.Count() == 0) tokens = new Queue<string>(ReadLine().Split(new[] { ' ', '\t', }, StringSplitOptions.RemoveEmptyEntries));
                return tokens.Dequeue();
            }

            public char ReadChar() { return ReadToken()[0]; }
            public sbyte ReadByte() { return sbyte.Parse(ReadToken()); }
            public short ReadShort() { return short.Parse(ReadToken()); }
            public int ReadInt() { return int.Parse(ReadToken()); }
            public long ReadLong() { return long.Parse(ReadToken()); }
            public float ReadFloat() { return float.Parse(ReadToken(), CultureInfo.InvariantCulture); }
            public double ReadDouble() { return double.Parse(ReadToken(), CultureInfo.InvariantCulture); }
            public decimal ReadDecimal() { return decimal.Parse(ReadToken(), CultureInfo.InvariantCulture); }
            public void Close() { reader.Close(); }
        }

        private static Reader In;
        private static TextWriter Out;

        private static int NUM_OF_TEST_CASES = 1; // TODO CHANGE NUMBER OF TEST CASES

        // TODO CHANGE FILE NAMES
        private static string INPUT_FILE_NAME = "input.txt";
        private static string OUTPUT_FILE_NAME = "output.txt";

        private static bool stdIn = true;
        private static bool stdOut = true;
        private static bool crash = true;
        private static bool flush = false;

        private static int STACK_MEMORY_LIMIT_MB = 150; // TODO CHANGE MEMORY LIMIT FOR STACK

        public static void Main(string[] args) {
            Thread T = new Thread(new ThreadStart(start), STACK_MEMORY_LIMIT_MB * 1000000);
            T.Start();
        }

        public static void start() {
            if (stdIn) In = new Reader(Console.OpenStandardInput());
            else In = new Reader(INPUT_FILE_NAME);
            if (stdOut) Out = new StreamWriter(Console.OpenStandardOutput());
            else Out = new StreamWriter(OUTPUT_FILE_NAME);
            for (int i = 1; i <= NUM_OF_TEST_CASES; i++) {
                try {
                    run(i);
                } catch (Exception e) {
                    Out.WriteLine("Exception thrown on test case " + i);
                    Out.WriteLine(e.StackTrace);
                    Out.Flush();
                    if (crash) throw new Exception();
                }
                if (flush) Out.Flush();
            }
            In.Close();
            Out.Close();
        }

        // TODO CODE GOES IN THIS METHOD
        public static void run(int testCaseNum) {
            int N = In.ReadInt();
            int[] P = new int[N / 2];
            for (int i = 0; i < N / 2; i++) P[i] = In.ReadInt();
            Array.Sort(P);
            int ans1 = 0, ans2 = 0;
            for (int i = 0; i < N / 2; i++) {
                ans1 += Math.Abs(i * 2 + 1 - P[i]);
                ans2 += Math.Abs(i * 2 + 2 - P[i]);
            }
            Out.WriteLine(Math.Min(ans1, ans2));
        }
    }
}

using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;
using static System.Diagnostics.Debug;

namespace EduRound44A {
    public class Program {
        public class Reader {
            private TextReader reader;
            private Queue<string> tokens;

            public Reader(Stream s) {
                reader = new StreamReader(s);
                tokens = new Queue<string>();
            }

            public Reader(string file) {
                reader = new StreamReader(file);
                tokens = new Queue<string>();
            }

            public string ReadLine() { return reader.ReadLine(); }

            public string ReadToken() {
                while (tokens.Count() == 0) tokens = new Queue<string>(ReadLine().Split(new[] { ' ', '\t', }, StringSplitOptions.RemoveEmptyEntries));
                return tokens.Dequeue();
            }

            public char ReadChar() { return ReadToken()[0]; }
            public sbyte ReadByte() { return sbyte.Parse(ReadToken()); }
            public short ReadShort() { return short.Parse(ReadToken()); }
            public int ReadInt() { return int.Parse(ReadToken()); }
            public long ReadLong() { return long.Parse(ReadToken()); }
            public float ReadFloat() { return float.Parse(ReadToken(), CultureInfo.InvariantCulture); }
            public double ReadDouble() { return double.Parse(ReadToken(), CultureInfo.InvariantCulture); }
            public decimal ReadDecimal() { return decimal.Parse(ReadToken(), CultureInfo.InvariantCulture); }
            public void Close() { reader.Close(); }
        }

        private static Reader In;
        private static TextWriter Out;

        private static int NUM_OF_TEST_CASES = 1; // TODO CHANGE NUMBER OF TEST CASES

        // TODO CHANGE FILE NAMES
        private static string INPUT_FILE_NAME = "input.txt";
        private static string OUTPUT_FILE_NAME = "output.txt";

        private static bool stdIn = true;
        private static bool stdOut = true;
        private static bool crash = true;
        private static bool flush = false;

        private static int STACK_MEMORY_LIMIT_MB = 150; // TODO CHANGE MEMORY LIMIT FOR STACK

        public static void Main(string[] args) {
            Thread T = new Thread(new ThreadStart(start), STACK_MEMORY_LIMIT_MB * 1000000);
            T.Start();
        }

        public static void start() {
            if (stdIn) In = new Reader(Console.OpenStandardInput());
            else In = new Reader(INPUT_FILE_NAME);
            if (stdOut) Out = new StreamWriter(Console.OpenStandardOutput());
            else Out = new StreamWriter(OUTPUT_FILE_NAME);
            for (int i = 1; i <= NUM_OF_TEST_CASES; i++) {
                try {
                    run(i);
                } catch (Exception e) {
                    Out.WriteLine("Exception thrown on test case " + i);
                    Out.WriteLine(e.StackTrace);
                    Out.Flush();
                    if (crash) throw new Exception();
                }
                if (flush) Out.Flush();
            }
            In.Close();
            Out.Close();
        }

        // TODO CODE GOES IN THIS METHOD
        public static void run(int testCaseNum) {
            int N = In.ReadInt();
            int[] P = new int[N / 2];
            for (int i = 0; i < N / 2; i++) P[i] = In.ReadInt();
            Array.Sort(P);
            int ans1 = 0, ans2 = 0;
            for (int i = 0; i < N / 2; i++) {
                ans1 += Math.Abs(i * 2 + 1 - P[i]);
                ans2 += Math.Abs(i * 2 + 2 - P[i]);
            }
            Out.WriteLine(Math.Min(ans1, ans2));
        }
    }
}

using System;
using System.Linq;

namespace _985A
{
    class Program
    {
        static void Main(string[] args)
        {
            bool fl = int.TryParse(Console.ReadLine(), out int n);
            if(!fl)
                throw new Exception("Different Input");
            var sp = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
            int [] pos = new int[n];
            for(int i = 0; i < sp.Length; ++i)
                pos[sp[i] - 1] = 1;
            var solve = new Solve(n, pos);
            System.Console.WriteLine(solve.Solver());
        }
    }

    internal class Solve {
        private int n { get; set; }
        private int [] posW { get; set; }

        private int [] posB { get; set; }

        public Solve(int N, int [] Pos){
            this.n = N;
            posW = Pos;
            posB = new int[posW.Length];
            Buffer.BlockCopy(posW, 0, posB, 0, n * sizeof(int));
        }

        public int Solver()
        {
            return SolverWB();
        }

        private int SolverWB()
        {
            var ps = n >> 1;
            var sol = new int[2] { 0, 0 };
            var idx = new int[2] { 0, n - 1 };
            for(int i = 0; i < ps; ++i, idx[0]+=2, idx[1]-=2)
            {
                for(int j = 0; j < n; ++j)
                    if(posW[j] != 0)
                    {
                        sol[0] += Math.Abs(j - idx[0]);
                        posW[j] = 0;
                        break;
                    }

                for(int j = n - 1; j >=0; --j)
                    if(posB[j] != 0)
                    {
                        sol[1] += Math.Abs(idx[1] - j);
                        posB[j] = 0;
                        break;
                    }
            }
            return Math.Min(sol[0], sol[1]);
        }
    }
}

using System;
using System.Linq;

namespace CSharp
{
    public class _985A
    {
        public static void Main()
        {
            int n = int.Parse(Console.ReadLine());
            int[] p = Console.ReadLine().Split().Select(token => int.Parse(token)).OrderBy(x => x).ToArray();

            int aCount = 0;
            int bCount = 0;

            for (int i = 0; i < n / 2; i++)
            {
                aCount += Math.Abs(2 * i + 1 - p[i]);
                bCount += Math.Abs(2 * i + 2 - p[i]);
            }

            Console.WriteLine(Math.Min(aCount, bCount));
        }
    }
}

using System;
using System.Linq;
using CompLib.Util;

public class Program
{

    public void Solve()
    {
        var sc = new Scanner();
        int n = sc.NextInt();
        int[] p = sc.IntArray();

        /*
         * 1*nグリッド
         * 駒iはP_iにいる
         * 全部の駒の位置の偶奇一致させる
         *
         *
         */

        int b = 0;
        int w = 0;
        Array.Sort(p);
        for(int i = 0;i < p.Length; i++)
        {
            // 現在地p_i
            // 目標 2*i+1
            b += Math.Abs(2 * i + 1 - p[i]);
            // 2*i+2
            w += Math.Abs(2 * i + 2 - p[i]);
        }

        Console.WriteLine(Math.Min(b,w));
    }

    public static void Main(string[] args) => new Program().Solve();
}

namespace CompLib.Util
{
    using System;
    using System.Linq;

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            if (_index >= _line.Length)
            {
                string s;
                do
                {
                    s = Console.ReadLine();
                } while (s.Length == 0);

                _line = s.Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public string ReadLine()
        {
            _index = _line.Length;
            return Console.ReadLine();
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            string s = Console.ReadLine();
            _line = s.Length == 0 ? new string[0] : s.Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}

using System;

namespace Codeforces {

    class Chess {

        static int N;
        static int numCount;
        static int[] an = new int[2000];

        static void ReadData() {
            Int32.TryParse(Console.ReadLine(), out N);
            var line = Console.ReadLine().Split(new char[]{' '});
            numCount = line.Length;
            for (int i = 1; i <= numCount; ++i)
            {
                Int32.TryParse(line[i-1], out an[i]);
            }
        }

        static int TrySolve(int color) {
            var result = 0;
            for (int i = 1; i<=numCount; ++i) {
                var loc = (i*2) - color;
                result += Math.Abs(an[i]-loc);
            }
            return result;
        }

        static void Main(string[] args) {
            ReadData();
            Array.Sort(an,1,numCount);
            Console.WriteLine(Math.Min(TrySolve(0), TrySolve(1)));
        }

    }
}

using System;
namespace Whatever {

    class ac {

        static int N;
        static int numCount;
        static int[] an = new int[2000];

        static void ReadData() {
            Int32.TryParse(Console.ReadLine(), out N);

            var line = Console.ReadLine().Split(new char[]{' '});

            numCount = line.Length;
            for (int i = 1; i <= numCount; ++i)
            {
                Int32.TryParse(line[i-1], out an[i]);
            }
        }

        static int TrySolve(int color) {
            var result = 0;
            for (int i = 1; i<=numCount; ++i) {
                var loc = (i*2) - color;
                result += Math.Abs(an[i]-loc);
            }

            return result;

        }

        static void Main(string[] args) {

            ReadData();
            Array.Sort(an,1,numCount);
            var minMoves = 2147483600;
            var tmp = TrySolve(0);
            if (tmp != -1 && tmp < minMoves) {
                minMoves = tmp;
            }
             tmp = TrySolve(1);
            if (tmp !=-1 && tmp < minMoves) {
                minMoves = tmp;
            }
            Console.WriteLine(minMoves);
        }

    }
}

using System;
using System.Collections.Generic;
using System.Linq;

namespace Расстановка_шахмат
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var arr = Console.ReadLine().Split(' ').Select(int.Parse).ToList();
            arr.Sort();
            var whites= new List<int>();
            var blacks = new List<int>();
            for(int i=0;i<n;i++)
                if (i % 2 == 0) blacks.Add(i+1);
            else whites.Add(i+1);
            int s1  =0;
            for (int i = 0; i < arr.Count; i++)
                s1 += Math.Abs(whites[i] - arr[i]);
            int s2 = 0;
            for (int i = 0; i < arr.Count; i++)
                s2 += Math.Abs(blacks[i] - arr[i]);
            Console.WriteLine(Math.Min(s1,s2));
           // Console.ReadKey();
        }
    }
}

using System;

namespace ConsoleApp3
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine())/2;
            int[] mass = new int[n];
            String[] s = Console.ReadLine().Split();

            for (int i = 0; i < n; i++)
            {
                mass[i] = int.Parse(s[i]);
            }
            Array.Sort(mass);
            int cnt = 0;
            int black = 1;
            for (int i = 0; i < n; i++)
            {
                cnt += Math.Abs(mass[i] - black);
                black += 2;
            }
            int cnt2 = 0;
            int white = 2;
            for (int i = 0; i < n; i++)
            {
                cnt2 += Math.Abs(mass[i] - white);
                white += 2;
            }
            Console.WriteLine(Math.Min(cnt, cnt2));
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Codeforces2105A
{
    class Program
    {
        static void Main(string[] args)
        {

            int n = int.Parse(Console.ReadLine());

            string read;
            read = Console.ReadLine();
            List<int> ArrayA = new List<int>();
            ArrayA = (read.Split(' ').ToList()).Select(s => int.Parse(s)).ToList();

            int black = 0;
            int white = 0;
            int blackindex = 1;
            int whiteindex = 2;
            ArrayA.Sort();

            foreach(var a in ArrayA)
            {
                black = black + Math.Abs(blackindex - a);
                white = white + Math.Abs(whiteindex - a);

                blackindex += 2;
                whiteindex += 2;
            }

            if (black > white)
                Console.WriteLine(white);
            else
                Console.WriteLine(black);

        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Threading;
using System.Runtime.CompilerServices;
using System.Text;
using System.Diagnostics;
using System.Numerics;
using static System.Console;
using static System.Convert;
using static System.Math;
using static Template;
using Pi = Pair<int, int>;

class Solver
{
    public Scanner sc;
    public void Solve()
    {
        var N = sc.Int;
        var P = sc.ArrInt;
        Array.Sort(P);
        var res = 0;
        for (int i = 0; i < N/2; i++)
        {
            res += Abs(2 * i - (P[i] - 1));
        }
        var r = 0;
        for (int i = 0; i < N / 2; i++)
        {
            r += Abs(2 * i+1 - (P[i] - 1));
        }
        Console.WriteLine(Min(res,r));
    }
}

#region Template
public static class Template
{
    static void Main(string[] args)
    {
        Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
        var sol = new Solver() { sc = new Scanner() };
        //var th = new Thread(sol.Solve, 1 << 26);th.Start();th.Join();
        sol.Solve();
        Console.Out.Flush();
    }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static bool chmin<T>(ref T a, T b) where T : IComparable<T> { if (a.CompareTo(b) > 0) { a = b; return true; } return false; }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static bool chmax<T>(ref T a, T b) where T : IComparable<T> { if (a.CompareTo(b) < 0) { a = b; return true; } return false; }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static void swap<T>(ref T a, ref T b) { var t = b; b = a; a = t; }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static void swap<T>(this IList<T> A, int i, int j) { var t = A[i]; A[i] = A[j]; A[j] = t; }
    public static T[] Create<T>(int n, Func<T> f) { var rt = new T[n]; for (var i = 0; i < rt.Length; ++i) rt[i] = f(); return rt; }
    public static T[] Create<T>(int n, Func<int, T> f) { var rt = new T[n]; for (var i = 0; i < rt.Length; ++i) rt[i] = f(i); return rt; }
    public static IEnumerable<T> Shuffle<T>(this IEnumerable<T> A) => A.OrderBy(v => Guid.NewGuid());
    public static int CompareTo<T>(this T[] A, T[] B, Comparison<T> cmp = null) { cmp = cmp ?? Comparer<T>.Default.Compare; for (var i = 0; i < Min(A.Length, B.Length); i++) { int c = cmp(A[i], B[i]); if (c > 0) return 1; else if (c < 0) return -1; } if (A.Length == B.Length) return 0; if (A.Length > B.Length) return 1; else return -1; }
    public static int ArgMax<T>(this IList<T> A, Comparison<T> cmp = null) { cmp = cmp ?? Comparer<T>.Default.Compare; T max = A[0]; int rt = 0; for (int i = 1; i < A.Count; i++) if (cmp(max, A[i]) < 0) { max = A[i]; rt = i; } return rt; }
    public static T PopBack<T>(this List<T> A) { var v = A[A.Count - 1]; A.RemoveAt(A.Count - 1); return v; }
    public static void Fail<T>(T s) { Console.WriteLine(s); Console.Out.Close(); Environment.Exit(0); }
}
public class Scanner
{
    public string Str => Console.ReadLine().Trim();
    public int Int => int.Parse(Str);
    public long Long => long.Parse(Str);
    public double Double => double.Parse(Str);
    public int[] ArrInt => Str.Split(' ').Select(int.Parse).ToArray();
    public long[] ArrLong => Str.Split(' ').Select(long.Parse).ToArray();
    public char[][] Grid(int n) => Create(n, () => Str.ToCharArray());
    public int[] ArrInt1D(int n) => Create(n, () => Int);
    public long[] ArrLong1D(int n) => Create(n, () => Long);
    public int[][] ArrInt2D(int n) => Create(n, () => ArrInt);
    public long[][] ArrLong2D(int n) => Create(n, () => ArrLong);
    private Queue<string> q = new Queue<string>();
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public T Next<T>() { if (q.Count == 0) foreach (var item in Str.Split(' ')) q.Enqueue(item); return (T)Convert.ChangeType(q.Dequeue(), typeof(T)); }
    public void Make<T1>(out T1 v1) => v1 = Next<T1>();
    public void Make<T1, T2>(out T1 v1, out T2 v2) { v1 = Next<T1>(); v2 = Next<T2>(); }
    public void Make<T1, T2, T3>(out T1 v1, out T2 v2, out T3 v3) { Make(out v1, out v2); v3 = Next<T3>(); }
    public void Make<T1, T2, T3, T4>(out T1 v1, out T2 v2, out T3 v3, out T4 v4) { Make(out v1, out v2, out v3); v4 = Next<T4>(); }
    public void Make<T1, T2, T3, T4, T5>(out T1 v1, out T2 v2, out T3 v3, out T4 v4, out T5 v5) { Make(out v1, out v2, out v3, out v4); v5 = Next<T5>(); }
    public void Make<T1, T2, T3, T4, T5, T6>(out T1 v1, out T2 v2, out T3 v3, out T4 v4, out T5 v5, out T6 v6) { Make(out v1, out v2, out v3, out v4, out v5); v6 = Next<T6>(); }
    public void Make<T1, T2, T3, T4, T5, T6, T7>(out T1 v1, out T2 v2, out T3 v3, out T4 v4, out T5 v5, out T6 v6, out T7 v7) { Make(out v1, out v2, out v3, out v4, out v5, out v6); v7 = Next<T7>(); }
    //public (T1, T2) Make<T1, T2>() { Make(out T1 v1, out T2 v2); return (v1, v2); }
    //public (T1, T2, T3) Make<T1, T2, T3>() { Make(out T1 v1, out T2 v2, out T3 v3); return (v1, v2, v3); }
    //public (T1, T2, T3, T4) Make<T1, T2, T3, T4>() { Make(out T1 v1, out T2 v2, out T3 v3, out T4 v4); return (v1, v2, v3, v4); }
}
public class Pair<T1, T2> : IComparable<Pair<T1, T2>>
{
    public T1 v1;
    public T2 v2;
    public Pair() { }
    public Pair(T1 v1, T2 v2)
    { this.v1 = v1; this.v2 = v2; }

    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public int CompareTo(Pair<T1, T2> p)
    {
        var c = Comparer<T1>.Default.Compare(v1, p.v1);
        if (c == 0)
            c = Comparer<T2>.Default.Compare(v2, p.v2);
        return c;
    }
    public override string ToString() => $"{v1.ToString()} {v2.ToString()}";
    public void Deconstruct(out T1 a, out T2 b) { a = v1; b = v2; }
}

public class Pair<T1, T2, T3> : Pair<T1, T2>, IComparable<Pair<T1, T2, T3>>
{
    public T3 v3;
    public Pair() : base() { }
    public Pair(T1 v1, T2 v2, T3 v3) : base(v1, v2)
    { this.v3 = v3; }

    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public int CompareTo(Pair<T1, T2, T3> p)
    {
        var c = base.CompareTo(p);
        if (c == 0)
            c = Comparer<T3>.Default.Compare(v3, p.v3);
        return c;
    }
    public override string ToString() => $"{base.ToString()} {v3.ToString()}";
    public void Deconstruct(out T1 a, out T2 b, out T3 c) { Deconstruct(out a, out b); c = v3; }
}
#endregion

using System;
using System.IO;
using System.Text;

namespace Chess_Placing
{
    internal class Program
    {
        private static readonly StreamReader reader = new StreamReader(Console.OpenStandardInput(1024*10), Encoding.ASCII, false, 1024*10);
        private static readonly StreamWriter writer = new StreamWriter(Console.OpenStandardOutput(1024*10), Encoding.ASCII, 1024*10);

        private static void Main(string[] args)
        {
            writer.WriteLine(Solve(args));
            writer.Flush();
        }

        private static int Solve(string[] args)
        {
            int n = Next();

            var nn = new int[n/2];
            for (int i = 0; i < nn.Length; i++)
            {
                nn[i] = Next();
            }
            Array.Sort(nn);

            int first = 1;
            int count = 0;
            foreach (int i in nn)
            {
                count += Math.Abs(first - i);
                first += 2;
            }
            int min = count;

            first = 2;
            count = 0;
            foreach (int i in nn)
            {
                count += Math.Abs(first - i);
                first += 2;
            }
            return Math.Min(min, count);
        }

        private static int Next()
        {
            int c;
            int res = 0;
            do
            {
                c = reader.Read();
                if (c == -1)
                    return res;
            } while (c < '0' || c > '9');
            res = c - '0';
            while (true)
            {
                c = reader.Read();
                if (c < '0' || c > '9')
                    return res;
                res *= 10;
                res += c - '0';
            }
        }
    }
}

using System;
using System.Collections.Generic;

namespace _985A
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            List<int> pieces = new List<int>();
            var piece_indexes = Console.ReadLine().Split(' ');

            for (int i = 0; i < piece_indexes.Length; i++)
            {
                pieces.Add(int.Parse(piece_indexes[i]) - 1);
            }
            pieces.Sort();
            List<int> pieces_2 = new List<int>(pieces);

            int min_all_black = GetMinMoves(n, pieces, 0);
            int min_all_white = GetMinMoves(n, pieces_2, 1);
            Console.WriteLine("{0}", Math.Min(min_all_black, min_all_white));
            //Console.Read();
        }

        static int GetMinMoves(int n, List<int> pieces, int parity)
        {
            int result = 0;
            for (int i = 0; i < n; i++)
            {
                if (i % 2 == parity)
                {
                    result += Math.Abs(pieces[0] - i);
                    pieces.RemoveAt(0);
                }
            }
            return result;
        }
    }
}

using System;
using System.Linq;
using System.Diagnostics;
using System.Collections.Generic;
using static System.Math;

class P
{
    static void Main()
    {
        //偶数
        int n = int.Parse(Console.ReadLine());
        int[] p = Console.ReadLine().Split().Select(x => int.Parse(x) - 1).OrderBy(x => x).ToArray();
        int even = 0;
        int odd = 0;
        for (int i = 0; i < p.Length; i++)
        {
            even += Abs(p[i] - (i * 2));
            odd += Abs(p[i] - ((i * 2) + 1));
            //Debug.WriteLine($"{even} {odd} {(i * 2)} {(i * 2) + 1}");
        }
        Console.WriteLine(Min(even, odd));

    }
}

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Threading;

namespace ReadWriteTemplate
{
    public static class Solver
    {
        private static void SolveCase()
        {
            int n = ReadInt();
            int m = n / 2;
            int ans0 = 0;
            int ans1 = 0;
            int[] p = ReadIntArray();
            Array.Sort(p);
            for (int i = 0; i < m; i++)
            {
                ans0 += Math.Abs(2 * i + 1 - p[i]);
                ans1 += Math.Abs(2 * i + 2 - p[i]);
            }
            int ans = Math.Min(ans0, ans1);
            Writer.WriteLine(ans);
        }

        public static void Solve()
        {
            SolveCase();

            /*var sw = Stopwatch.StartNew();*/

            /*int T = ReadInt();
            for (int i = 0; i < T; i++)
            {
                Writer.Write("Case #{0}: ", i + 1);
                SolveCase();
            }*/

            /*sw.Stop();
            Console.WriteLine(sw.ElapsedMilliseconds);*/
        }

        public static void Main()
        {
            Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;

#if DEBUG
            //Reader = Console.In; Writer = Console.Out;
            Reader = File.OpenText("input.txt"); Writer = File.CreateText("output.txt");
#else
            Reader = Console.In; Writer = Console.Out;
#endif

            //Solve();
            Thread thread = new Thread(Solve, 64 * 1024 * 1024);
            thread.CurrentCulture = CultureInfo.InvariantCulture;
            thread.Start();
            thread.Join();

            Reader.Close();
            Writer.Close();
        }

        public static IOrderedEnumerable<TSource> OrderByWithShuffle<TSource, TKey>(this IEnumerable<TSource> source, Func<TSource, TKey> keySelector)
        {
            return source.Shuffle().OrderBy(keySelector);
        }

        public static T[] Shuffle<T>(this IEnumerable<T> source)
        {
            T[] result = source.ToArray();
            Random rnd = new Random();
            for (int i = result.Length - 1; i >= 1; i--)
            {
                int k = rnd.Next(i + 1);
                T tmp = result[k];
                result[k] = result[i];
                result[i] = tmp;
            }
            return result;
        }

        #region Read/Write

        private static TextReader Reader;

        private static TextWriter Writer;

        private static Queue<string> CurrentLineTokens = new Queue<string>();

        private static string[] ReadAndSplitLine()
        {
            return Reader.ReadLine().Split(new[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
        }

        public static string ReadToken()
        {
            while (CurrentLineTokens.Count == 0)
                CurrentLineTokens = new Queue<string>(ReadAndSplitLine());
            return CurrentLineTokens.Dequeue();
        }

        public static string ReadLine()
        {
            return Reader.ReadLine();
        }

        public static int ReadInt()
        {
            return int.Parse(ReadToken());
        }

        public static long ReadLong()
        {
            return long.Parse(ReadToken());
        }

        public static double ReadDouble()
        {
            return double.Parse(ReadToken(), CultureInfo.InvariantCulture);
        }

        public static int[] ReadIntArray()
        {
            return ReadAndSplitLine().Select(int.Parse).ToArray();
        }

        public static long[] ReadLongArray()
        {
            return ReadAndSplitLine().Select(long.Parse).ToArray();
        }

        public static double[] ReadDoubleArray()
        {
            return ReadAndSplitLine().Select(s => double.Parse(s, CultureInfo.InvariantCulture)).ToArray();
        }

        public static int[][] ReadIntMatrix(int numberOfRows)
        {
            int[][] matrix = new int[numberOfRows][];
            for (int i = 0; i < numberOfRows; i++)
                matrix[i] = ReadIntArray();
            return matrix;
        }

        public static string[] ReadLines(int quantity)
        {
            string[] lines = new string[quantity];
            for (int i = 0; i < quantity; i++)
                lines[i] = Reader.ReadLine().Trim();
            return lines;
        }

        public static void WriteArray<T>(IEnumerable<T> array)
        {
            Writer.WriteLine(string.Join(" ", array));
        }

        #endregion
    }
}

using System;
namespace Whatever {

    class asearch {

        static int N;
        static int numCount;
        static int[] an = new int[2000];

        static void ReadData() {
            Int32.TryParse(Console.ReadLine(), out N);

            var line = Console.ReadLine().Split(new char[]{' '});

            numCount = line.Length;
            for (int i = 1; i <= numCount; ++i)
            {
                Int32.TryParse(line[i-1], out an[i]);
            }
        }

        // BWBWBWBW
        // 101010101  mod 2
        static int NextLoc(int start, int color) {
            if (start % 2 == color) {
                return start;
            } else {
                return start+1;
            }
        }

        static int TrySolve(int color) {
            var poop = new bool[10000];
            var solved = new bool[10000];
            for (int i = 1; i<=numCount; ++i) {
                if (an[i] %2 == color) {
                    poop[an[i]] =true;
                    solved[i] = true;
                } else {
                    solved[i] =false;
                }
            }

            var result = 0;

            for (int i = 1; i<=numCount; ++i) {
                if (!solved[i]) {
                    var plc = -1;
                    var plcDis = 10101010;
                    for (int j = 1; j<=N; ++j) {
                        if (j%2 == color && !poop[j] && Math.Abs(j-an[i]) < plcDis) {
                            plcDis = Math.Abs(j-an[i]);
                            plc = j;
                        }
                    }
                    poop[plc] = true;
                    solved[i] = true;
                    result += Math.Abs(plc-an[i]);
                }
            }

            return result;

        }

        static void Main(string[] args) {

            ReadData();
            var minMoves = 2147483600;
            var tmp = TrySolve(0);
            if (tmp != -1 && tmp < minMoves) {
                minMoves = tmp;
            }
             tmp = TrySolve(1);
            if (tmp !=-1 && tmp < minMoves) {
                minMoves = tmp;
            }
            Console.WriteLine(minMoves);
            //Console.WriteLine(Console.ReadLine());
        }

    }
}

using System;
namespace Whatever {

    class asearch {

        static int N;
        static int numCount;
        static int[] an = new int[2000];

        static void ReadData() {
            Int32.TryParse(Console.ReadLine(), out N);

            var line = Console.ReadLine().Split(new char[]{' '});

            numCount = line.Length;
            for (int i = 1; i <= numCount; ++i)
            {
                Int32.TryParse(line[i-1], out an[i]);
            }
        }

        // BWBWBWBW
        // 101010101  mod 2
        static int NextLoc(int start, int color) {
            if (start % 2 == color) {
                return start;
            } else {
                return start+1;
            }
        }

        static int TrySolve(int color) {
            var poop = new bool[10000];
            var solved = new bool[10000];
            for (int i = 1; i<=numCount; ++i) {
                if (an[i] %2 == color) {
                    poop[an[i]] =true;
                    solved[i] = true;
                } else {
                    solved[i] =false;
                }
            }

            var result = 0;

            for (int i = 1; i<=numCount; ++i) {
                if (!solved[i]) {
                    var plc = -1;
                    var plcDis = 10101010;
                    for (int j = 1; j<=N; ++j) {
                        if (j%2 == color && !poop[j] && Math.Abs(j-an[i]) < plcDis) {
                            plcDis = Math.Abs(j-an[i]);
                            plc = j;
                        }
                    }
                    poop[plc] = true;
                    solved[i] = true;
                    result += Math.Abs(plc-an[i]);
                }
            }

            return result;

        }

        static void Main(string[] args) {

            ReadData();
            Array.Sort(an,1,numCount);
            var minMoves = 2147483600;
            var tmp = TrySolve(0);
            if (tmp != -1 && tmp < minMoves) {
                minMoves = tmp;
            }
             tmp = TrySolve(1);
            if (tmp !=-1 && tmp < minMoves) {
                minMoves = tmp;
            }
            Console.WriteLine(minMoves);
            //Console.WriteLine(Console.ReadLine());
        }

    }
}

using System;
namespace Whatever {

    class a {

        static int N;
        static int numCount;
        static int[] an = new int[2000];

        static void ReadData() {
            Int32.TryParse(Console.ReadLine(), out N);

            var line = Console.ReadLine().Split(new char[]{' '});

            numCount = line.Length;
            for (int i = 1; i <= numCount; ++i)
            {
                Int32.TryParse(line[i-1], out an[i]);
            }
        }

        // BWBWBWBW
        // 101010101  mod 2
        static int NextLoc(int start, int color) {
            if (start % 2 == color) {
                return start;
            } else {
                return start+1;
            }
        }

        static int TrySolve(int color) {
            var newLoc = new int[10000];
            var lastLocation = 0;
            for (int i = 1; i<=numCount; ++i) {
                var nextAvail = NextLoc(lastLocation+1, color);
                if (nextAvail < an[i]) {
                    if (an[i]%2 == color) {
                        newLoc[i] = an[i];
                        lastLocation = an[i];
                    } else if (an[i] - 1 >= nextAvail && an[i] -1 >0) {
                        newLoc[i] = an[i] - 1;
                        lastLocation = newLoc[i];
                    }
                } else {
                    newLoc[i] = nextAvail;
                    lastLocation = nextAvail;
                }
            }
            var result = 0;
            for (int i = 1; i<=numCount; ++i) {
                //Console.WriteLine($"{an[i]}->{newLoc[i]}");
                result += Math.Abs(newLoc[i] - an[i]);
                if (newLoc[i] > N || newLoc[i] < 1) {
                    return -1;
                }

            }

            return result;

        }

        static void Main(string[] args) {

            ReadData();
            var minMoves = 2147483600;
            var tmp = TrySolve(0);
            if (tmp != -1 && tmp < minMoves) {
                minMoves = tmp;
            }
            tmp = TrySolve(1);
            if (tmp !=-1 && tmp < minMoves) {
                minMoves = tmp;
            }
            Console.WriteLine(minMoves);
            //Console.WriteLine(Console.ReadLine());
        }

    }
}

using System;
namespace Whatever {

    class a {

        static int N;
        static int numCount;
        static int[] an = new int[2000];

        static void ReadData() {
            Int32.TryParse(Console.ReadLine(), out N);

            var line = Console.ReadLine().Split(new char[]{' '});

            numCount = line.Length;
            for (int i = 1; i <= numCount; ++i)
            {
                Int32.TryParse(line[i-1], out an[i]);
            }
        }

        // BWBWBWBW
        // 101010101  mod 2
        static int NextLoc(int start, int color) {
            if (start % 2 == color) {
                return start;
            } else {
                return start+1;
            }
        }

        static int TrySolve(int color) {
            var newLoc = new int[10000];
            var lastLocation = 0;
            for (int i = 1; i<=numCount; ++i) {
                var nextAvail = NextLoc(lastLocation+1, color);
                if (nextAvail < an[i]) {
                    if (an[i]%2 == color) {
                        newLoc[i] = an[i];
                        lastLocation = an[i];
                    } else if (an[i] - 1 >= nextAvail && an[i] -1 >0) {
                        newLoc[i] = an[i] - 1;
                        lastLocation = newLoc[i];
                    } else {
                        newLoc[i] = an[i] +1;
                        lastLocation = newLoc[i];
                    }
                } else {
                    /*if (an[i]%2 ==color && nextAvail == an[i]) {
                        newLoc[i] = an[i];
                    } else {*/
                        newLoc[i] = nextAvail;
                        lastLocation = nextAvail;
                    /*}*/

                }
            }
            var result = 0;
            for (int i = 1; i<=numCount; ++i) {
                // Console.WriteLine($"{an[i]}->{newLoc[i]}");
                result += Math.Abs(newLoc[i] - an[i]);
                if (newLoc[i] > N || newLoc[i] < 1) {
                    return -1;
                }

            }

            return result;

        }

        static void Main(string[] args) {

            ReadData();
            var minMoves = 2147483600;
            var tmp = TrySolve(0);
            if (tmp != -1 && tmp < minMoves) {
                minMoves = tmp;
            }
             tmp = TrySolve(1);
            if (tmp !=-1 && tmp < minMoves) {
                minMoves = tmp;
            }
            Console.WriteLine(minMoves);
            //Console.WriteLine(Console.ReadLine());
        }

    }
}

using System;
using System.Collections.Generic;
using System.Linq;

namespace Расстановка_шахмат
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var arr = Console.ReadLine().Split(' ').Select(int.Parse).ToList();
            var whites= new List<int>();
            var blacks = new List<int>();
            for(int i=0;i<n;i++)
                if (i % 2 == 0) blacks.Add(i+1);
            else whites.Add(i+1);
            int s1  =0;
            for (int i = 0; i < arr.Count; i++)
                s1 += Math.Abs(whites[i] - arr[i]);
            int s2 = 0;
            for (int i = 0; i < arr.Count; i++)
                s2 += Math.Abs(blacks[i] - arr[i]);
            Console.WriteLine(Math.Min(s1,s2));
           // Console.ReadKey();
        }
    }
}

using System;
using System.Text;
using System.Collections.Generic;

namespace ForAcm
{
	class MainClass
	{
		public static void Main (string[] args)
		{
//			string t = Console.ReadLine ();
//			int it = int.Parse (t);
			Solve solve = new Solve ();
			solve.init ();
//			int i = 0;
//			while (it > 0) {
//				it--;
//				i++;
				solve.doit ();
				//solve.output (i);
//			}
		}
	}

	class Solve{
		private int  ans;
		private List<int> a = new List<int>();
		public void init(){
			a.Clear ();
			string s = Console.ReadLine ();
			int n = int.Parse (s);
			s = Console.ReadLine ();
			string[] ss = s.Split (' ');
			for (int i = 0; i < n / 2; i++) {
				a.Add(int.Parse (ss[i]) - 1);
			}

			int s1 = 0;
			int s2 = 0;
			for (int i = 0; i < n / 2; i++) {
				s1 += Math.Abs( a [i] - i * 2);
				s2 += Math.Abs( a[i] - i* 2 - 1);
			}
			if (s1 < s2)
				Console.WriteLine (s1);
			else
				Console.WriteLine (s2);
		}
		public void doit(){
		}

		/*public void output(int i){
			Console.WriteLine (string.Format ("Case #{0}: {1}", i, ans));
		}*/
	}
}

using System;
using System.Text;
using System.Collections.Generic;

namespace ForAcm
{
	class MainClass
	{
		public static void Main (string[] args)
		{
//			string t = Console.ReadLine ();
//			int it = int.Parse (t);
			Solve solve = new Solve ();
			solve.init ();
//			int i = 0;
//			while (it > 0) {
//				it--;
//				i++;
				solve.doit ();
				//solve.output (i);
//			}
		}
	}

	class Solve{
		private int  ans;
		private int[] a = new int[100];
		public void init(){
			string s = Console.ReadLine ();
			int n = int.Parse (s);
			s = Console.ReadLine ();
			string[] ss = s.Split (' ');
			for (int i = 0; i < n / 2; i++) {
				a[i] = int.Parse (ss[i]) - 1;
			}
			int s1 = 0;
			int s2 = 0;
			for (int i = 0; i < n / 2; i++) {
				s1 += Math.Abs( a [i] - i * 2);
				s2 += Math.Abs( a[i] - i* 2 - 1);
			}
			if (s1 < s2)
				Console.WriteLine (s1);
			else
				Console.WriteLine (s2);
		}
		public void doit(){
		}

		/*public void output(int i){
			Console.WriteLine (string.Format ("Case #{0}: {1}", i, ans));
		}*/
	}
}

using System;

namespace ConsoleApp3
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine())/2;
            int[] mass = new int[n];
            String[] s = Console.ReadLine().Split();
            for (int i = 0; i < n; i++)
            {
                mass[i] = int.Parse(s[i]);
            }
            int cnt = 0;
            int black = 1;
            for (int i = 0; i < n; i++)
            {
                cnt += Math.Abs(mass[i] - black);
                black += 2;
            }
            int cnt2 = 0;
            int white = 2;
            for (int i = 0; i < n; i++)
            {
                cnt2 += Math.Abs(mass[i] - white);
                white += 2;
            }
            Console.WriteLine(Math.Min(cnt, cnt2));
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Codeforces2105A
{
    class Program
    {
        static void Main(string[] args)
        {

            int n = int.Parse(Console.ReadLine());

            string read;
            read = Console.ReadLine();
            List<int> ArrayA = new List<int>();
            ArrayA = (read.Split(' ').ToList()).Select(s => int.Parse(s)).ToList();

            int black = 0;
            int white = 0;
            int blackindex = 1;
            int whiteindex = 2;
            foreach(var a in ArrayA)
            {
                black = black + Math.Abs(blackindex - a);
                white = white + Math.Abs(whiteindex - a);

                blackindex += 2;
                whiteindex += 2;
            }

            if (black > white)
                Console.WriteLine(white);
            else
                Console.WriteLine(black);

        }
    }
}

using System;
using System.IO;
using System.Text;

namespace Chess_Placing
{
    internal class Program
    {
        private static readonly StreamReader reader = new StreamReader(Console.OpenStandardInput(1024*10), Encoding.ASCII, false, 1024*10);
        private static readonly StreamWriter writer = new StreamWriter(Console.OpenStandardOutput(1024*10), Encoding.ASCII, 1024*10);

        private static void Main(string[] args)
        {
            writer.WriteLine(Solve(args));
            writer.Flush();
        }

        private static int Solve(string[] args)
        {
            int n = Next();

            var nn = new int[n/2];
            for (int i = 0; i < nn.Length; i++)
            {
                nn[i] = Next();
            }

            int first = 1;
            int count = 0;
            foreach (int i in nn)
            {
                count += Math.Abs(first - i);
                first += 2;
            }
            int min = count;

            first = 2;
            count = 0;
            foreach (int i in nn)
            {
                count += Math.Abs(first - i);
                first += 2;
            }
            return Math.Min(min, count);
        }

        private static int Next()
        {
            int c;
            int res = 0;
            do
            {
                c = reader.Read();
                if (c == -1)
                    return res;
            } while (c < '0' || c > '9');
            res = c - '0';
            while (true)
            {
                c = reader.Read();
                if (c < '0' || c > '9')
                    return res;
                res *= 10;
                res += c - '0';
            }
        }
    }
}

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Threading;

namespace ReadWriteTemplate
{
    public static class Solver
    {
        private static void SolveCase()
        {
            int n = ReadInt();
            int m = n / 2;
            int ans0 = 0;
            int ans1 = 0;
            for (int i = 0; i < m; i++)
            {
                int p = ReadInt() - 1;
                ans0 += Math.Abs(2 * i - p);
                ans1 += Math.Abs(2 * i + 1 - p);
            }
            int ans = Math.Min(ans0, ans1);
            Writer.WriteLine(ans);
        }

        public static void Solve()
        {
            SolveCase();

            /*var sw = Stopwatch.StartNew();*/

            /*int T = ReadInt();
            for (int i = 0; i < T; i++)
            {
                Writer.Write("Case #{0}: ", i + 1);
                SolveCase();
            }*/

            /*sw.Stop();
            Console.WriteLine(sw.ElapsedMilliseconds);*/
        }

        public static void Main()
        {
            Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;

#if DEBUG
            //Reader = Console.In; Writer = Console.Out;
            Reader = File.OpenText("input.txt"); Writer = File.CreateText("output.txt");
#else
            Reader = Console.In; Writer = Console.Out;
#endif

            //Solve();
            Thread thread = new Thread(Solve, 64 * 1024 * 1024);
            thread.CurrentCulture = CultureInfo.InvariantCulture;
            thread.Start();
            thread.Join();

            Reader.Close();
            Writer.Close();
        }

        public static IOrderedEnumerable<TSource> OrderByWithShuffle<TSource, TKey>(this IEnumerable<TSource> source, Func<TSource, TKey> keySelector)
        {
            return source.Shuffle().OrderBy(keySelector);
        }

        public static T[] Shuffle<T>(this IEnumerable<T> source)
        {
            T[] result = source.ToArray();
            Random rnd = new Random();
            for (int i = result.Length - 1; i >= 1; i--)
            {
                int k = rnd.Next(i + 1);
                T tmp = result[k];
                result[k] = result[i];
                result[i] = tmp;
            }
            return result;
        }

        #region Read/Write

        private static TextReader Reader;

        private static TextWriter Writer;

        private static Queue<string> CurrentLineTokens = new Queue<string>();

        private static string[] ReadAndSplitLine()
        {
            return Reader.ReadLine().Split(new[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
        }

        public static string ReadToken()
        {
            while (CurrentLineTokens.Count == 0)
                CurrentLineTokens = new Queue<string>(ReadAndSplitLine());
            return CurrentLineTokens.Dequeue();
        }

        public static string ReadLine()
        {
            return Reader.ReadLine();
        }

        public static int ReadInt()
        {
            return int.Parse(ReadToken());
        }

        public static long ReadLong()
        {
            return long.Parse(ReadToken());
        }

        public static double ReadDouble()
        {
            return double.Parse(ReadToken(), CultureInfo.InvariantCulture);
        }

        public static int[] ReadIntArray()
        {
            return ReadAndSplitLine().Select(int.Parse).ToArray();
        }

        public static long[] ReadLongArray()
        {
            return ReadAndSplitLine().Select(long.Parse).ToArray();
        }

        public static double[] ReadDoubleArray()
        {
            return ReadAndSplitLine().Select(s => double.Parse(s, CultureInfo.InvariantCulture)).ToArray();
        }

        public static int[][] ReadIntMatrix(int numberOfRows)
        {
            int[][] matrix = new int[numberOfRows][];
            for (int i = 0; i < numberOfRows; i++)
                matrix[i] = ReadIntArray();
            return matrix;
        }

        public static string[] ReadLines(int quantity)
        {
            string[] lines = new string[quantity];
            for (int i = 0; i < quantity; i++)
                lines[i] = Reader.ReadLine().Trim();
            return lines;
        }

        public static void WriteArray<T>(IEnumerable<T> array)
        {
            Writer.WriteLine(string.Join(" ", array));
        }

        #endregion
    }
}

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

namespace Practice
{
    public class Program
    {
        public static void Main()
        {
            ConsoleReader r = new ConsoleReader();
            BufferedStream w = new BufferedStream(Console.OpenStandardOutput());
            Solve(r, w);
            //Console.ReadKey();
        }

        public static void Solve(ConsoleReader reader, BufferedStream writer)
        {
            A(reader, writer);
        }
        public static void C()
        {

        }

        public static void B(ConsoleReader reader, BufferedStream writer)
        {
        }
        public static void A(ConsoleReader reader, BufferedStream writer)
        {
            int n = reader.ReadInt()/2;
            int bMoves = 0, wMoves = 0;
            for (int i =0; i<n; i++)
            {
                int t = reader.ReadInt();
                bMoves += Math.Abs(2*i + 1 - t);
                wMoves += Math.Abs(2*i + 2 - t);
            }

            Console.WriteLine(Math.Min(bMoves, wMoves));
        }
    }

    public class ConsoleReader
    {
        private String[] data;
        private int wordIndex = 0;

        private void ReadLineIfNeeded()
        {
            while (data == null || wordIndex >= data.Length)
            {
                wordIndex = 0;
                data = Console.ReadLine().Trim().Split();
            }
        }
        public int ReadInt()
        {
            ReadLineIfNeeded();
            return int.Parse(data[wordIndex++]);
        }

        public void ReadArray(int[] a, int n)
        {
            for (int i = 0; i < n; i++)
            {
                a[i] = ReadInt();
            }
        }

        public string ReadString()
        {
            ReadLineIfNeeded();
            return data[wordIndex++];
        }

        //ReadLine()

    }

}

using System;
using System.Linq;

namespace _985A
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int zoma = n / 2, oddCount=0,evenCount=0;
            int[] posArray = new int[zoma];
            var inputs = Console.ReadLine().Split().Select(int.Parse);
            posArray = inputs.ToArray();
            for (int i=n, j = zoma-1; i > 0; i-=2,j--)
                if (posArray[j] != i) evenCount+= Math.Abs(i - posArray[j]);
            for (int i = n-1, j = zoma - 1; i > 0; i -= 2, j--)
                if (posArray[j] != i)  oddCount+= Math.Abs(i - posArray[j]);
            Console.WriteLine(evenCount < oddCount ? evenCount : oddCount);
        }
    }
}

using System;

namespace CF_985_A
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = Convert.ToInt32(Console.ReadLine());
            n = n / 2;
            int[] a = new int[n];
            string[] s = Console.ReadLine().Split();
            for (int i = 0; i < n; i++)
            {
                a[i] = Convert.ToInt32(s[i]);
            }
            int nb = CountMoves(n, a, 1);
            int nw = CountMoves(n, a, 2);
            Console.WriteLine(Math.Min(nb, nw));
        }

        private static int CountMoves(int n, int[] a, int first)
        {
            int cnt = 0;
            for (int i = 0; i < n; i++)
            {
                cnt += Math.Abs(i*2+first - a[i]);
            }
            return cnt;
        }
    }
}

using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;
using static System.Diagnostics.Debug;

namespace QTREE3 {
    public class Program {
        public class Reader {
            private TextReader reader;
            private Queue<string> tokens;

            public Reader(Stream s) {
                reader = new StreamReader(s);
                tokens = new Queue<string>();
            }

            public Reader(string file) {
                reader = new StreamReader(file);
                tokens = new Queue<string>();
            }

            public string ReadLine() { return reader.ReadLine(); }

            public string ReadToken() {
                while (tokens.Count() == 0) tokens = new Queue<string>(ReadLine().Split(new[] { ' ', '\t', }, StringSplitOptions.RemoveEmptyEntries));
                return tokens.Dequeue();
            }

            public char ReadChar() { return ReadToken()[0]; }
            public sbyte ReadByte() { return sbyte.Parse(ReadToken()); }
            public short ReadShort() { return short.Parse(ReadToken()); }
            public int ReadInt() { return int.Parse(ReadToken()); }
            public long ReadLong() { return long.Parse(ReadToken()); }
            public float ReadFloat() { return float.Parse(ReadToken(), CultureInfo.InvariantCulture); }
            public double ReadDouble() { return double.Parse(ReadToken(), CultureInfo.InvariantCulture); }
            public decimal ReadDecimal() { return decimal.Parse(ReadToken(), CultureInfo.InvariantCulture); }
            public void Close() { reader.Close(); }
        }

        private static Reader In;
        private static TextWriter Out;

        private static int NUM_OF_TEST_CASES = 1; // TODO CHANGE NUMBER OF TEST CASES

        // TODO CHANGE FILE NAMES
        private static string INPUT_FILE_NAME = "input.txt";
        private static string OUTPUT_FILE_NAME = "output.txt";

        private static bool stdIn = true;
        private static bool stdOut = true;
        private static bool crash = true;
        private static bool flush = false;

        private static int STACK_MEMORY_LIMIT_MB = 150; // TODO CHANGE MEMORY LIMIT FOR STACK

        public static void Main(string[] args) {
            Thread T = new Thread(new ThreadStart(start), STACK_MEMORY_LIMIT_MB * 1000000);
            T.Start();
        }

        public static void start() {
            if (stdIn) In = new Reader(Console.OpenStandardInput());
            else In = new Reader(INPUT_FILE_NAME);
            if (stdOut) Out = new StreamWriter(Console.OpenStandardOutput());
            else Out = new StreamWriter(OUTPUT_FILE_NAME);
            for (int i = 1; i <= NUM_OF_TEST_CASES; i++) {
                try {
                    run(i);
                } catch (Exception e) {
                    Out.WriteLine("Exception thrown on test case " + i);
                    Out.WriteLine(e.StackTrace);
                    Out.Flush();
                    if (crash) throw new Exception();
                }
                if (flush) Out.Flush();
            }
            In.Close();
            Out.Close();
        }

        // TODO CODE GOES IN THIS METHOD
        public static void run(int testCaseNum) {
            int N = In.ReadInt();
            int ans1 = 0, ans2 = 0;
            for (int i = 1; i <= N / 2; i++) {
                int p = In.ReadInt();
                ans1 += Math.Abs(i * 2 - p);
                ans2 += Math.Abs(i * 2 - 1 - p);
            }
            Out.WriteLine(Math.Min(ans1, ans2));
        }
    }
}

using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;
using static System.Diagnostics.Debug;

namespace QTREE3 {
    public class Program {
        public class Reader {
            private TextReader reader;
            private Queue<string> tokens;

            public Reader(Stream s) {
                reader = new StreamReader(s);
                tokens = new Queue<string>();
            }

            public Reader(string file) {
                reader = new StreamReader(file);
                tokens = new Queue<string>();
            }

            public string ReadLine() { return reader.ReadLine(); }

            public string ReadToken() {
                while (tokens.Count() == 0) tokens = new Queue<string>(ReadLine().Split(new[] { ' ', '\t', }, StringSplitOptions.RemoveEmptyEntries));
                return tokens.Dequeue();
            }

            public char ReadChar() { return ReadToken()[0]; }
            public sbyte ReadByte() { return sbyte.Parse(ReadToken()); }
            public short ReadShort() { return short.Parse(ReadToken()); }
            public int ReadInt() { return int.Parse(ReadToken()); }
            public long ReadLong() { return long.Parse(ReadToken()); }
            public float ReadFloat() { return float.Parse(ReadToken(), CultureInfo.InvariantCulture); }
            public double ReadDouble() { return double.Parse(ReadToken(), CultureInfo.InvariantCulture); }
            public decimal ReadDecimal() { return decimal.Parse(ReadToken(), CultureInfo.InvariantCulture); }
            public void Close() { reader.Close(); }
        }

        private static Reader In;
        private static TextWriter Out;

        private static int NUM_OF_TEST_CASES = 1; // TODO CHANGE NUMBER OF TEST CASES

        // TODO CHANGE FILE NAMES
        private static string INPUT_FILE_NAME = "input.txt";
        private static string OUTPUT_FILE_NAME = "output.txt";

        private static bool stdIn = true;
        private static bool stdOut = true;
        private static bool crash = true;
        private static bool flush = false;

        private static int STACK_MEMORY_LIMIT_MB = 150; // TODO CHANGE MEMORY LIMIT FOR STACK

        public static void Main(string[] args) {
            Thread T = new Thread(new ThreadStart(start), STACK_MEMORY_LIMIT_MB * 1000000);
            T.Start();
        }

        public static void start() {
            if (stdIn) In = new Reader(Console.OpenStandardInput());
            else In = new Reader(INPUT_FILE_NAME);
            if (stdOut) Out = new StreamWriter(Console.OpenStandardOutput());
            else Out = new StreamWriter(OUTPUT_FILE_NAME);
            for (int i = 1; i <= NUM_OF_TEST_CASES; i++) {
                try {
                    run(i);
                } catch (Exception e) {
                    Out.WriteLine("Exception thrown on test case " + i);
                    Out.WriteLine(e.StackTrace);
                    Out.Flush();
                    if (crash) throw new Exception();
                }
                if (flush) Out.Flush();
            }
            In.Close();
            Out.Close();
        }

        // TODO CODE GOES IN THIS METHOD
        public static void run(int testCaseNum) {
            int N = In.ReadInt();
            int[] P = new int[N / 2];
            for (int i = 0; i < N / 2; i++) P[i] = In.ReadInt();
            int ans1 = 0, ans2 = 0;
            for (int i = 0; i < N / 2; i++) {
                ans1 += Math.Abs(i * 2 + 1 - P[i]);
                ans2 += Math.Abs(i * 2 + 2 - P[i]);
            }
            Out.WriteLine(Math.Min(ans1, ans2));
        }
    }
}

using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;
using static System.Diagnostics.Debug;

namespace QTREE3 {
    public class Program {
        public class Reader {
            private TextReader reader;
            private Queue<string> tokens;

            public Reader(Stream s) {
                reader = new StreamReader(s);
                tokens = new Queue<string>();
            }

            public Reader(string file) {
                reader = new StreamReader(file);
                tokens = new Queue<string>();
            }

            public string ReadLine() { return reader.ReadLine(); }

            public string ReadToken() {
                while (tokens.Count() == 0) tokens = new Queue<string>(ReadLine().Split(new[] { ' ', '\t', }, StringSplitOptions.RemoveEmptyEntries));
                return tokens.Dequeue();
            }

            public char ReadChar() { return ReadToken()[0]; }
            public sbyte ReadByte() { return sbyte.Parse(ReadToken()); }
            public short ReadShort() { return short.Parse(ReadToken()); }
            public int ReadInt() { return int.Parse(ReadToken()); }
            public long ReadLong() { return long.Parse(ReadToken()); }
            public float ReadFloat() { return float.Parse(ReadToken(), CultureInfo.InvariantCulture); }
            public double ReadDouble() { return double.Parse(ReadToken(), CultureInfo.InvariantCulture); }
            public decimal ReadDecimal() { return decimal.Parse(ReadToken(), CultureInfo.InvariantCulture); }
            public void Close() { reader.Close(); }
        }

        private static Reader In;
        private static TextWriter Out;

        private static int NUM_OF_TEST_CASES = 1; // TODO CHANGE NUMBER OF TEST CASES

        // TODO CHANGE FILE NAMES
        private static string INPUT_FILE_NAME = "input.txt";
        private static string OUTPUT_FILE_NAME = "output.txt";

        private static bool stdIn = true;
        private static bool stdOut = true;
        private static bool crash = true;
        private static bool flush = false;

        private static int STACK_MEMORY_LIMIT_MB = 150; // TODO CHANGE MEMORY LIMIT FOR STACK

        public static void Main(string[] args) {
            Thread T = new Thread(new ThreadStart(start), STACK_MEMORY_LIMIT_MB * 1000000);
            T.Start();
        }

        public static void start() {
            if (stdIn) In = new Reader(Console.OpenStandardInput());
            else In = new Reader(INPUT_FILE_NAME);
            if (stdOut) Out = new StreamWriter(Console.OpenStandardOutput());
            else Out = new StreamWriter(OUTPUT_FILE_NAME);
            for (int i = 1; i <= NUM_OF_TEST_CASES; i++) {
                try {
                    run(i);
                } catch (Exception e) {
                    Out.WriteLine("Exception thrown on test case " + i);
                    Out.WriteLine(e.StackTrace);
                    Out.Flush();
                    if (crash) throw new Exception();
                }
                if (flush) Out.Flush();
            }
            In.Close();
            Out.Close();
        }

        // TODO CODE GOES IN THIS METHOD
        public static void run(int testCaseNum) {
            int N = In.ReadInt();
            int ans1 = 0, ans2 = 0;
            for (int i = 1; i <= N / 2; i++) {
                int p = In.ReadInt();
                ans1 += Math.Abs(i * 2 - p);
                ans2 += Math.Abs(i * 2 + 1 - p);
            }
            Out.WriteLine(Math.Min(ans1, ans2));
        }
    }
}

using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;
using static System.Diagnostics.Debug;

namespace QTREE3 {
    public class Program {
        public class Reader {
            private TextReader reader;
            private Queue<string> tokens;

            public Reader(Stream s) {
                reader = new StreamReader(s);
                tokens = new Queue<string>();
            }

            public Reader(string file) {
                reader = new StreamReader(file);
                tokens = new Queue<string>();
            }

            public string ReadLine() { return reader.ReadLine(); }

            public string ReadToken() {
                while (tokens.Count() == 0) tokens = new Queue<string>(ReadLine().Split(new[] { ' ', '\t', }, StringSplitOptions.RemoveEmptyEntries));
                return tokens.Dequeue();
            }

            public char ReadChar() { return ReadToken()[0]; }
            public sbyte ReadByte() { return sbyte.Parse(ReadToken()); }
            public short ReadShort() { return short.Parse(ReadToken()); }
            public int ReadInt() { return int.Parse(ReadToken()); }
            public long ReadLong() { return long.Parse(ReadToken()); }
            public float ReadFloat() { return float.Parse(ReadToken(), CultureInfo.InvariantCulture); }
            public double ReadDouble() { return double.Parse(ReadToken(), CultureInfo.InvariantCulture); }
            public decimal ReadDecimal() { return decimal.Parse(ReadToken(), CultureInfo.InvariantCulture); }
            public void Close() { reader.Close(); }
        }

        private static Reader In;
        private static TextWriter Out;

        private static int NUM_OF_TEST_CASES = 1; // TODO CHANGE NUMBER OF TEST CASES

        // TODO CHANGE FILE NAMES
        private static string INPUT_FILE_NAME = "input.txt";
        private static string OUTPUT_FILE_NAME = "output.txt";

        private static bool stdIn = true;
        private static bool stdOut = true;
        private static bool crash = true;
        private static bool flush = false;

        private static int STACK_MEMORY_LIMIT_MB = 150; // TODO CHANGE MEMORY LIMIT FOR STACK

        public static void Main(string[] args) {
            Thread T = new Thread(new ThreadStart(start), STACK_MEMORY_LIMIT_MB * 1000000);
            T.Start();
        }

        public static void start() {
            if (stdIn) In = new Reader(Console.OpenStandardInput());
            else In = new Reader(INPUT_FILE_NAME);
            if (stdOut) Out = new StreamWriter(Console.OpenStandardOutput());
            else Out = new StreamWriter(OUTPUT_FILE_NAME);
            for (int i = 1; i <= NUM_OF_TEST_CASES; i++) {
                try {
                    run(i);
                } catch (Exception e) {
                    Out.WriteLine("Exception thrown on test case " + i);
                    Out.WriteLine(e.StackTrace);
                    Out.Flush();
                    if (crash) throw new Exception();
                }
                if (flush) Out.Flush();
            }
            In.Close();
            Out.Close();
        }

        // TODO CODE GOES IN THIS METHOD
        public static void run(int testCaseNum) {
            int N = In.ReadInt();
            int ans1 = 0, ans2 = 0;
            for (int i = 1; i <= N / 2; i++) {
                int p = In.ReadInt();
                ans1 += Math.Abs(p - i * 2);
                ans2 += Math.Abs(p - i * 2 + 1);
            }
            Out.WriteLine(Math.Min(ans1, ans2));
        }
    }
}