input: from typing import List
  
  
  def number_of_subarrays(nums: List[int]) -> int:
      """
      You are given an array of positive integers nums.
      Return the number of subarrays of nums, where the first and the last elements of the subarray are equal to the largest element in the subarray.
      
      Parameters:
      nums (List[int]): The input array of positive integers.
      
      Returns:
      int: The number of subarrays fulfilling the condition.
      
      Examples:
      >>> number_of_subarrays([1, 4, 3, 3, 2])
      6
      >>> number_of_subarrays([3, 3, 3])
      6
      >>> number_of_subarrays([1])
      1
      """
  
output: 
      count = 0
      for i in range(len(nums)):
          max_val = nums[i]
          for j in range(i, len(nums)):
              max_val = max(max_val, nums[j])
              if nums[i] == max_val and nums[j] == max_val:
                  count += 1
      return count
  