You are provided with array of positive non-zero ints and int n representing n-th power (n >= 2).

For the given array, calculate the sum of each value to the n-th power. Then subtract the sum of the original array.

Example 1: Input: {1, 2, 3}, 3 --> (1 ^ 3 + 2 ^ 3 + 3 ^ 3 ) - (1 + 2 + 3) --> 36 - 6 --> Output: 30

Example 2: Input: {1, 2}, 5  --> (1 ^ 5 + 2 ^ 5) - (1 + 2) --> 33 - 3 --> Output: 30

Difficulty: introductory

Starter code:

def modified_sum(a, n):
	

Solutions:
def modified_sum(lst, p):
    return sum(n**p - n for n in lst)

def modified_sum(a, n):
    return sum(i ** n for i in a) - sum(a)

def modified_sum(a, n):
    return sum([x ** n - x for x in a])

def modified_sum(a, n):
    return sum(i**n - i for i in a)

def modified_sum(a, n):
    ans = 0
    for sq in a:
        ans = ans + sq ** n
        
    
    return ans - sum(a)


def modified_sum(a, n):
    L=[]
    for i in a:
        L.append(i**n)
    return sum(L)-sum(a)

def modified_sum(a, n):
    sum = 0
    for x in a:
        sum += x**n - x
    return sum

def modified_sum(a, n):
      s1=0
      s2=0
      for x in a:
          s1+=x**n
          s2+=x
      return s1-s2

def modified_sum(a, n):
      return sum([i**n for i in a]) - sum(a)

def modified_sum(a, n):
    return sum(x**n - x for x in a)