program sample
    implicit none
    
    integer(8) :: a,b,c,i,j,m,n,k,a1,b1,c1
    integer(8), allocatable  ::x(:) 
    read(*,*) n
  
    read(*,*) k
    allocate(x(n))
    read(*,*) x
    m=0
    do i=1,k
        m=m+n-abs(n-2*x(i))
    end do
    write(*,*)m
    deallocate(x)
    stop
end program sample
  

