import java.util.*;
import java.io.*;

public class RowsOfStarsOmkar {
    public static void main(String[] args) throws IOException {
        BufferedReader f = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
        StringTokenizer st = new StringTokenizer(f.readLine());

        int n = Integer.parseInt(st.nextToken());
        int k = Integer.parseInt(st.nextToken());
        int p = Integer.parseInt(st.nextToken());
        int q = Integer.parseInt(st.nextToken());

        int[] arr = new int[n];
        int[] duparr = new int[2*n];
        for(int i = 0; i < n; i++){
            arr[i] = Integer.parseInt(f.readLine());
            duparr[i] = arr[i];
            duparr[i+n] = arr[i];
        }

        long[] pSubrows = new long[n];
        long currsum = 0;
        for(int i = 0; i < n+q-1; i++){
            currsum+=duparr[i];
            if(i >= q-1){
                pSubrows[i-q+1] = currsum;
                currsum-=duparr[i-q+1];
            }
        }

        // this will store the index of the top-left element of the subrectangle with sum of a given ID
        int buckets = gcd(n, k);
        int bucketLen = n/buckets;
        long[][] subrows = new long[buckets][bucketLen];
        int[][] sumToIndex = new int[buckets][bucketLen];
        for(int bucket = 0; bucket < buckets; bucket++) {
            int idx = bucket;
            for(int i = 0; i < bucketLen; i++){
                subrows[bucket][i] = pSubrows[idx];
                sumToIndex[bucket][i] = idx;
                idx+=k;
                idx%=n;
            }
        }
        long[][] subrowSums = new long[buckets][bucketLen];
        for(int bucket = 0; bucket < buckets; bucket++) {
            long totsum = 0;
            for(int i = 0; i < bucketLen; i++) totsum+=subrows[bucket][i];
            int mult = p/bucketLen;
            int extra = p%bucketLen;
            long currsum2 = totsum*mult;
            for(int i = 0; i < bucketLen+extra; i++){
                if(i >= extra){
                   subrowSums[bucket][(i-extra)%bucketLen] = currsum2;
                   currsum2-=subrows[bucket][(i-extra)%bucketLen];
                }
                currsum2+=subrows[bucket][i%bucketLen];
            }
        }

        // now we check which subrow sums actually exist in the grid

        boolean all = false;
        int[] markers = new int[2*n];
        int start = 0;
        for(int i = 0; i < n-p+1; i++){
            int end = (start+(n-q+1));
            if(end-start >= n){
                all = true;
                break;
            }
            markers[start]++;
            markers[end]--;
            start+=k;
            start%=n;
        }
        int[] exists = new int[2*n];
        int startVal = 0;
        for(int i = 0; i < 2*n; i++){
            startVal+=markers[i];
            exists[i] = startVal;
        }
        boolean[] elements = new boolean[n];
        for(int i = 0; i < n; i++){
            if(exists[i] != 0 || exists[i+n] != 0){
                elements[i] = true;
            }
        }

        long ans = Long.MIN_VALUE;
        for(int i = 0; i < buckets; i++){
            for(int j = 0; j < bucketLen; j++){
                if(all || elements[sumToIndex[i][j]]) ans = Math.max(ans, subrowSums[i][j]);
            }
        }

        out.println(ans);
        out.close();


    }
    public static int gcd(int a, int b){
        while(b != 0){
            int t = b;
            b = a % b;
            a = t;
        }
        return a;
    }
}
