import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int k = sc.nextInt();
        long P = sc.nextLong();

        long[] a = new long[n + 1];

        for (int i = 1; i <= n; i++) {
            a[i] = sc.nextLong();
        }

        long NEG_INF = Long.MIN_VALUE / 4;

        long[][] dp = new long[n + 1][k + 1];

        for (int i = 0; i <= n; i++) {
            Arrays.fill(dp[i], NEG_INF);
        }

        dp[0][0] = 0;

        for (int i = 1; i <= n; i++) {
            dp[i][0] = 0;

            for (int j = 1; j <= k; j++) {

                // Don't take i
                dp[i][j] = dp[i - 1][j];

                // Take i, but don't take i-1
                if (i >= 2 && dp[i - 2][j - 1] != NEG_INF) {
                    dp[i][j] = Math.max(
                        dp[i][j],
                        a[i] + dp[i - 2][j - 1]
                    );
                }

                // Take both i-1 and i -> pay penalty P
                if (i >= 2 && j >= 2 && dp[i - 2][j - 2] != NEG_INF) {
                    dp[i][j] = Math.max(
                        dp[i][j],
                        a[i] + a[i - 1] - P + dp[i - 2][j - 2]
                    );
                }
            }
        }

        System.out.println(dp[n][k]);

        sc.close();
    }
}