n, k, x = map(lambda s_: int(s_), input().split()) a = tuple(map(lambda s_: int(s_), input().split())) q = [] tot = 0 from heapq import heappush, heappop ans = -(10**20) for i, ai in enumerate(a, 1): heappush(q, ai) tot += ai while len(q) > k: e = heappop(q) tot -= e ans = max(ans, tot - i * x) print(ans)