input: 
  from typing import List
  
  def count_special_subarrays(nums: List[int]) -> int:
      """
      Given an array of positive integers, compute how many subarrays exist such that both the first and last elements are equal to the maximum element in that subarray.
  
      Parameters:
      nums (List[int]): An array of positive integers.
  
      Returns:
      int: The total count of subarrays meeting the criteria.
  
      Examples:
      >>> count_special_subarrays([1, 4, 3, 3, 2])
      6
      >>> count_special_subarrays([3, 3, 3])
      6
      >>> count_special_subarrays([1])
      1
      """
  
output:     
      n = len(nums)
      count = 0
      
      for i in range(n):
          max_elem = nums[i]
          for j in range(i, n):
              if nums[j] > max_elem:
                  max_elem = nums[j]
              if nums[i] == max_elem and nums[j] == max_elem:
                  count += 1
      
      return count
  