input: Write a function that takes an array of integers as input and determines if it is possible to obtain a non-decreasing sorted array by performing any number of right shift operations. If it is possible, the function should return True, otherwise, it should return False. If the input array is empty, the function should return True.
  
  Here's the function signature and implementation based on the instructions given:
  
  def can_sort_by_shifting_right(arr):
      if not arr:
          return True
      n = len(arr)
      pivot = -1
      
      # Find the pivot where the sequence breaks
      for i in range(1, n):
          if arr[i] < arr[i - 1]:
              pivot = i
              break
      
      # If no pivot found, array is already sorted
      if pivot == -1:
          return True
      
      # Check if shifting the segment [pivot, n-1] to the start results in a sorted array
      for i in range(pivot, n):
          if arr[i] < arr[i - 1]:
              return False
      
      # Check if the last element of shifted array is smaller than or equal to the first element of the original array
      if arr[-1] <= arr[0]:
          return True
      
      return False
  
  # Additional test cases
  assert can_sort_by_shifting_right([3, 4, 5, 1, 2]) == True
  assert can_sort_by_shifting_right([1, 2, 3, 4, 5]) == True
  assert can_sort_by_shifting_right([4, 5, 1, 2, 3]) == True
  assert can_sort_by_shifting_right([4, 3, 2, 1]) == False
  assert can_sort_by_shifting_right([]) == True
output: def can_sort_by_shifting_right(arr):
      if not arr:
          return True
      n = len(arr)
      pivot = -1
      
      # Find the pivot where the sequence breaks
      for i in range(1, n):
          if arr[i] < arr[i - 1]:
              pivot = i
              break
      
      # If no pivot found, array is already sorted
      if pivot == -1:
          return True
      
      # Check if shifting the segment [pivot, n-1] to the start results in a sorted array
      for i in range(pivot, n):
          if arr[i] < arr[i - 1]:
              return False
      
      # Check if the last element of shifted array is smaller than or equal to the first element of the original array
      if arr[-1] <= arr[0]:
          return True
      
      return False