program main
  implicit none
  integer :: A, B, Q
  integer , allocatable :: s(:) , t(:), x(:)
  integer :: i, j ,k
  integer ::lsum(4)

  read(*,*) a, b, q
  allocate(s(a))
  allocate(t(b))
  allocate(x(q))

  do i = 1, a
     read(*,*) s(i)
  end do
  do i = 1, b
     read(*,*) t(i)
  end do
  do i = 1, q
     read(*,*) x(i)
     do j = 1, a-1
        if( s(j).le. x(i) .and. s(j+1).ge.x(i) )then
           do k = 1, b-1
              if (t(k) .le. x(i) .and. t(k+1) .ge.x(i) ) then
                 lsum(1) = x(i) - s(j) + abs(t(k)-s(j))
                 lsum(2) = x(i) - s(j) + abs(t(k+1)-s(j))
                 lsum(3) = s(j+1) -x(i) + abs(t(k) - s(j+1))
                 lsum(4) = s(j+1) -x(i) + abs(t(k+1) - s(j+1))
              end if
           end do
        end if
     end do
  end do

  write(*,'(i0)') minval(lsum,4)
  

end program main
