def switches(L:list) -> int:
  count = 0
  # first count the switches involving L[0]
  for x in L[1:]:
    if x < L[0]:
      count += 1
  
  # count the switches in the remaining part of the list, 
  # namely L[1:]  
  if len(L) > 1:
    count += switches(L[1:])
  
  return count


def switches_iterative(L):
  i = 0
  count = 0
  
  for i in range(len(L)):
    for x in L[i+1:]:
      if x < L[i]:
        count += 1  
        
  return count