import sys import math #from collections import deque, defaultdict, Counter #import heapq #import bisect #import itertools #import functools # 外部ライブラリ(AtCoder環境で利用可能) #from sortedcontainers import SortedList, SortedSet, SortedDict #from atcoder.dsu import DSU #from atcoder.segtree import SegTree #from atcoder.lazysegtree import LazySegTree #from atcoder.fenwicktree import FenwickTree # 入力高速化 #input = sys.stdin.readline # 再帰回数上限 # よくあるmod #MOD = 1000000007 MOD = 998244353 def solve(): # 解答ここから N, K, X = map(int, input().split(' ')) A = list(map(int, input().split(' '))) cnt = 0 cur = 0 # sum ans = -10000000000000 import heapq hq = [] for i in range(N): cur += A[i] heapq.heappush(hq, A[i]) cnt += 1 if cnt == K+1: cur -= heapq.heappop(hq) cnt -= 1 ans = max(ans, cur - (i+1) * X) print(ans) if __name__ == '__main__': T = 1 for _ in range(T): solve()