import heapq import sys imput = sys.stdin.readline n, k, x = map(int, input().split()) a = list(map(int, input().split())) hq = [] top = 0 ans = -10 ** 18 for i in range(1, n + 1): t = a[i - 1] heapq.heappush(hq, t) top += t if len(hq) > k: removed = heapq.heappop(hq) top -= removed #print(hq) result = top - i * x if result > ans: ans = result print(ans)