/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */


import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
      Scanner sc=new Scanner(System.in);
      int n=sc.nextInt();
      int[] a=new int[n/2+1];
      for(int i=1;i<=n/2;i++){
          a[i]=sc.nextInt();
      }
      int say=0,k=n-1;
      int h=n;
      for(int i=n/2;i>=1;i--){
         int j;
          for(j=k;j>=1;j-=2){
              int data=Math.abs(a[i]-j);
              System.out.println("k1: "+k);
              say+=data;break;
          }
          k=j-2;
      }
        System.out.println(say);
        
    }
    
}
