from heapq import heappush, heappop N, K, X = map(int, input().split()) A = list(map(int, input().split())) L = [] total = 0 ans = -1e18 for i in range(N): a = A[i] heappush(L, a) total += a if i >= K: rm = heappop(L) total -= rm memo = total - (i + 1)*X if memo > ans: ans = memo print(ans)