input: from typing import List
  from math import isqrt
  
  def max_prime_index_diff(nums: List[int]) -> int:
      """
      You are given an integer array nums.
  
      Return an integer that is the maximum distance between the indices of two (not necessarily different) prime numbers in nums.
  
      Examples:
      >>> nums = [4,2,9,5,3]
      3
      >>> nums = [4,8,2,8]
      0
  
      Constraints:
      1 <= nums.length <= 3 * 10^5
      1 <= nums[i] <= 100
      The input is generated such that the number of prime numbers in the nums is at least one.
      """
  
output: 
      def is_prime(n):
          if n <= 1:
              return False
          if n == 2:
              return True
          if n % 2 == 0:
              return False
          for i in range(3, isqrt(n) + 1, 2):
              if n % i == 0:
                  return False
          return True
  
      prime_indices = [i for i, num in enumerate(nums) if is_prime(num)]
      if len(prime_indices) < 2:
          return 0
      return max(prime_indices) - min(prime_indices)
  