input: from typing import List
  
  def min_cost_to_split_array(nums: List[int]) -> int:
      """
      You are given an array of integers nums of length n.
  
      The cost of an array is the value of its first element. For example, the cost of [1,2,3] is 1 while the cost of [3,4,1] is 3.
  
      You need to divide nums into 3 disjoint contiguous subarrays.
  
      Return the minimum possible sum of the cost of these subarrays.
  
      Examples:
      >>> nums = [1,2,3,12]
      6
      >>> nums = [5,4,3]
      12
      >>> nums = [10,3,1,1]
      12
  
      Constraints:
      3 <= n <= 50
      1 <= nums[i] <= 50
      """
  
output: 
      n = len(nums)
      if n < 3:
          return sum(nums)
      
      # Initialize dp array
      dp = [[float('inf')] * 3 for _ in range(n)]
      
      # Base case
      dp[0][0] = nums[0]
      
      for i in range(1, n):
          dp[i][0] = min(dp[i-1][0], nums[i])
          dp[i][1] = min(dp[i-1][1], dp[i-1][0] + nums[i])
          dp[i][2] = min(dp[i-1][2], dp[i-1][1] + nums[i])
      
      return dp[n-1][2]
  