import bisect
import math

N, K = map(int, input().split())
nums = list(map(int, input().split()))

total = 0
nums.sort()


def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))


#i = 0

# K >= 2
#if K == 1:
    
#else:
for i in range(0, len(nums) - K + 1):
    for k in range(i + K - 1, len(nums)):
            #print("i, k", nums[i], nums[k])
        count = nums[k] - nums[i]
        diff = k - 1 - i
            #print("diff:", diff, K - 2)
            #print("conb:", combinations_count(diff, K - 2))
        total += 1#combinations_count(diff, K - 2) * count
        #print("total", total)
print(total)
