import heapq n, k, x = map(int, input().split()) a = list(map(int, input().split())) score = 0 h = [] ans = -(1<<60) for i, ai in enumerate(a): score += ai heapq.heappush(h, ai) if len(h) > k: m = heapq.heappop(h) score -= m res = score - x * (i + 1) ans = max(ans, res) print(ans)