input: Write a Python function that takes an integer array nums and returns the maximum possible total cost after optimally splitting the array into several subarrays, ensuring each element belongs to exactly one subarray. The cost of a subarray nums[l..r] is computed as:
  
  cost(l, r) = nums[l] - nums[l + 1] + ... + nums[r] * (−1)^(r − l)
  
  Formally, if nums is split into k subarrays at indices i_1, i_2,..., i_k-1, where 0 <= i_1 < i_2 < ... < i_k - 1 < n - 1, the total cost will be:
  
  cost(0, i_1) + cost(i_1 + 1, i_2) + ... + cost(i_k − 1 + 1, n − 1)
  
  If the array is not split, the total cost is simply cost(0, n - 1).
  
  Examples:
  >>> nums = [1, -2, 3, 4]
  10
  >>> nums = [1, -1, 1, -1]
  4
  
  Constraints:
  1 <= nums.length <= 10^5
  -10^9 <= nums[i] <= 10^9
output: def maxTotalCost(nums):
      total_cost = 0
      for i in range(len(nums)):
          if i % 2 == 0:
              total_cost += nums[i]
          else:
              total_cost -= nums[i]
      return total_cost