input: Write a python function to find the mode of a sorted array.
  assert findMode([1, 2, 2, 3, 4, 4, 4, 5, 6])==4
  assert findMode([7, 7, 8, 8, 8, 9, 9])==8
  assert findMode([1, 1, 2, 2, 3, 3, 3])==3
output: def findMode(arr):
      mode = arr[0]
      max_count = curr_count = 1
      curr_element = arr[0]
      
      for i in range(1, len(arr)):
          if arr[i] == curr_element:
              curr_count += 1
          else:
              if curr_count > max_count:
                  max_count = curr_count
                  mode = curr_element
              curr_element = arr[i]
              curr_count = 1
      
      if curr_count > max_count:
          mode = curr_element
      
      return mode