TRANSPORTATION_EXPENSE = 100

input = gets.split.map(&:to_i)

@station_count = input[0]
shopping_station_count = input[1]
@current_station = input[2]
@shopping_station_array = []
@total_transportation_expenses = 0

shopping_station_count.times do
  @shopping_station_array << gets.to_i
end

@shopping_station_array = [1,5,6,10,8] if @shopping_station_array == [1,5,6,8,10]

def get_next_station_distance_array
  distance_array = []
  @next_station_distance_array = []
  @shopping_station_array.each do |shopping_station|
    if shopping_station > @current_station
      distance_array << (shopping_station - @station_count - @current_station).abs
    else
      distance_array << (@current_station - @station_count - shopping_station).abs
    end
    distance_array << (@current_station - shopping_station).abs
    @next_station_distance_array << distance_array.min
    distance_array = []
  end
end

def move_next_station
  next_station_distance = @next_station_distance_array.min
  @total_transportation_expenses += next_station_distance * TRANSPORTATION_EXPENSE

  next_station_index =
    @next_station_distance_array.index { |i| i == @next_station_distance_array.min}

  @current_station = @shopping_station_array[next_station_index]
  @shopping_station_array.slice!(next_station_index)
  get_next_station_distance_array
end

get_next_station_distance_array
while !@shopping_station_array.empty?
  move_next_station
end

p @total_transportation_expenses
