from heapq import heappush, heappop n, k, x = map(int, input().split()) ans = -10 ** 18 cost = sm = 0 q = [] for a in map(int, input().split()): cost += x heappush(q, a) sm += a if len(q) == k + 1: sm -= heappop(q) ans = max(ans, sm - cost) print(ans)