input: from typing import List
  
  def power_sum(nums: List[int], k: int) -> int:
      """
      Given an array nums of integers of size n and a positive integer k.
  
      Calculate the power of an array, defined as the count of subsequences whose sums equal k.
  
      Return the total power sum of all such subsequences in nums.
  
      Since the result can be quite large, return it modulo 10^9 + 7.
  
      Examples:
      >>> nums = [1,2,3], k = 3
      6
      >>> nums = [2,3,3], k = 5
      4
      >>> nums = [1,2,3], k = 7
      0
  
      Constraints:
      1 <= n <= 100
      1 <= nums[i] <= 10^4
      1 <= k <= 100
      """
output:     MOD = 10**9 + 7
  
      def count_subsequences(nums, n, k):
          dp = [[0 for _ in range(k + 1)] for _ in range(n + 1)]
  
          for i in range(n + 1):
              dp[i][0] = 1
  
          for i in range(1, n + 1):
              for j in range(1, k + 1):
                  dp[i][j] = dp[i-1][j]
                  if nums[i-1] <= j:
                      dp[i][j] = (dp[i][j] + dp[i-1][j-nums[i-1]]) % MOD
  
          return dp[n][k]
  
      return count_subsequences(nums, len(nums), k)