This morning, Roman woke up and opened the browser with n opened tabs numbered from 1 to n. There are two kinds of tabs: those with the information required for the test and those with social network sites. Roman decided that there are too many tabs open so he wants to close some of them.

He decided to accomplish this by closing every k-th (2 ≤ k ≤ n - 1) tab. Only then he will decide whether he wants to study for the test or to chat on the social networks. Formally, Roman will choose one tab (let its number be b) and then close all tabs with numbers c = b + i ⋅ k that satisfy the following condition: 1 ≤ c ≤ n and i is an integer (it may be positive, negative or zero).

For example, if k = 3, n = 14 and Roman chooses b = 8, then he will close tabs with numbers 2, 5, 8, 11 and 14.

After closing the tabs Roman will calculate the amount of remaining tabs with the information for the test (let's denote it e) and the amount of remaining social network tabs (s). Help Roman to calculate the maximal absolute value of the difference of those values |e - s| so that it would be easy to decide what to do next.

Input

The first line contains two integers n and k (2 ≤ k < n ≤ 100) — the amount of tabs opened currently and the distance between the tabs closed.

The second line consists of n integers, each of them equal either to 1 or to -1. The i-th integer denotes the type of the i-th tab: if it is equal to 1, this tab contains information for the test, and if it is equal to -1, it's a social network tab.

Output

Output a single integer — the maximum absolute difference between the amounts of remaining tabs of different types |e - s|.

Examples

Input


4 2
1 1 -1 1


Output


2


Input


14 3
-1 1 -1 -1 1 -1 -1 1 -1 -1 1 -1 -1 1


Output


9

Note

In the first example we can choose b = 1 or b = 3. We will delete then one tab of each type and the remaining tabs are then all contain test information. Thus, e = 2 and s = 0 and |e - s| = 2.

In the second example, on the contrary, we can leave opened only tabs that have social networks opened in them.
    import java.util.*;

    import javax.lang.model.util.ElementScanner6;

    import java.io.*;

    public class Main{

        public static void main(String[] args) {

            InputStream inputStream = System.in;
            OutputStream outputStream = System.out;
            InputReader inp = new InputReader(inputStream);
            PrintWriter out = new PrintWriter(outputStream);
            Solver solver = new Solver();
            solver.solve(inp, out);
            out.close();
            
            }



        static class Solver {


            class Node implements Comparable<Node>{
                int i;
                long c;
            
                Node(int i,long c)
                {
                    this.i=i;
                    this.c=c;
                    

                }

            public int compareTo(Node n)
                {
                    return Long.compare(this.c, n.c);
                }
            }

            public boolean done(int[] sp,int[] par)
            {
                int root;

                root=findSet(sp[0],par);
                
            for(int i=1;i<sp.length;i++)
            {
                    if(root!=findSet(sp[i], par))
                        return false;
            }
            return true;
            }
        public int findSet(int i,int[] par)
        {
            int x =i;
                boolean flag =false;
                while(par[i]>=0)
                {
                    flag = true;
                    i=par[i];
                }
                if(flag)
                    par[x]=i;
                return i;
        }

        public void unionSet(int i,int j,int[] par)
        {
                int x = findSet(i, par);
                int y = findSet(j, par);
                if(x<y)
                {
                    par[y]=x;
                }
                else
                {
                    par[x]=y;
                }
        }

        public  long pow(long a, long b, long MOD) {
                if (b == 0) {
                    return 1;
                }
                if (b == 1) {
                    return a;
                }
                long val = pow(a, b / 2, MOD);
                if (b % 2 == 0) {
                    return val * val % MOD;
                } else {
                    return val * (val * a % MOD) % MOD;

                }
            
            }


            public void minPrimeFactor(int n,int[] s)
            {
                boolean prime[] = new boolean[n+1];
                Arrays.fill(prime, true);
                s[1]=1;
                s[2]=2;
                for(int i=4;i<=n;i+=2)
                {
                    prime[i]=false;
                    s[i]=2;
                }

                for(int i=3;i<=n;i+=2)
                {
                    if(prime[i])
                    {
                        s[i]=i;
                        for(int j=2*i;j<=n;j+=i)
                        {
                            prime[j]=false;
                            s[j]=i;
                        }
                    }
                }
                
            }

            
            // public void findAllPrime(int n,ArrayList<Node> al,int s[])
            // {
            //     int curr = s[n];
            //     int cnt = 1;
            //     while(n>1)
            //     {
            //         n/=s[n];
            //         if(curr==s[n])
            //         {
            //             cnt++;
            //             continue;

            //         }
            //         Node n1 = new Node(curr,cnt);
            //         al.add(n1);

            //         curr=s[n];
            //         cnt=1;
            //     }
            // }

            

            public int binarySearch(int n,int k)
            {
                int left=1;
                int right=100000000+5;
                int ans=0;
                while(left<=right)
                {
                    int mid = (left+right)/2;
                    if(n/mid>=k)
                    {
                        left = mid+1;
                        ans=mid;
                    }
                    else
                    {
                        right=mid-1;
                    }
                }

                return ans;
            }
            public boolean checkPallindrom(String s)
            {
                char ch[] = s.toCharArray();

                for(int i=0;i<s.length()/2;i++)
                {
                    if(ch[i]!=ch[s.length()-1-i])
                        return false;
                }
                return true;
            }


            public void dfs_util(ArrayList<Integer>[] al,boolean vis[],int x,int cnt[],int sts[],int fts[],long sv[])
            {
                    
                vis[x] = true;
                long min=Long.MAX_VALUE;
                    sts[cnt[0]]=x+1;
                    for(int i=0;i<al[x].size();i++)
                    {
                        
                        if(!vis[al[x].get(i)])
                        {
                            cnt[0]++;
                            dfs_util(al, vis, al[x].get(i),cnt,sts,fts,sv);
                            if(sv[al[x].get(i)]<min&&sv[al[x].get(i)]!=-1)
                            {
                                min=sv[al[x].get(i)];
                            }
                            
                            
                        }    
                        
                    }

                
                    if(sv[x]==-1)
                    {
                        if(min==Long.MAX_VALUE)
                        {
                            min=-1;
                        }
                        sv[x]=min;
                    }
                
                
                return ;
            }

            public void dfs(ArrayList[] al,int sts[],int fts[],long sv[])
            {
                
            boolean vis[] = new boolean[al.length];
            int cnt[]= new int[2*al.length+2];
            for(int i=0;i<al.length;i++)
            {
                    if(!vis[i])
                    {
                        
                        dfs_util(al,vis,i,cnt,sts,fts,sv);
                    }
            }
            }
    
            public void remove(ArrayList<Integer>[] al,int x)
            {
                for(int i=0;i<al.length;i++)
                {
                    for(int j=0;j<al[i].size();j++)
                    {

                        if(al[i].get(j)==x)
                            al[i].remove(j);

                    }
                }
            }

            public int gcd(int a, int b) 
            { 
                if (a == 0) 
                    return b; 
                return gcd(b % a, a); 
            }


            public void printDivisors(long n,ArrayList<Long> al) 
            { 
                // Note that this loop runs till square root 
                for (long i=1; i<=Math.sqrt(n); i++) 
                { 
                    if (n%i==0) 
                    { 
                        // If divisors are equal, print only one 
                        if (n/i == i) 
                            al.add(i);
            
                        else // Otherwise print both 
                            al.add(i);
                            al.add(n/i);
                    } 
                } 
            } 

            private void solve(InputReader inp, PrintWriter out1) {

                int n = inp.nextInt();
                int k = inp.nextInt();
                int arr[] = new int[n];
                int max=0;
                int count1=0;
                int count2=0;
                for(int i=0;i<n;i++)
                {
                    arr[i]=inp.nextInt();
                    if(arr[i]==1)
                    {
                        count1++;
                    }
                    else
                    {
                        count2++;
                    }
                }

                for(int b=0;b<k;b++)
                {
                    int start = b/k;
                    int cnt1=count1;
                    int cnt2=count2;
                    int last=(n-b-1)/k;
                    for(int i=start;i<=last;i++)
                    {
                        int t = b+(k*i);
                        if(arr[t]==-1)
                        {
                            cnt2--;
                        }
                        else
                        {
                            cnt1--;
                        }
                    }
                    if(Math.abs(cnt1-cnt2)>max)
                    {
                        max=Math.abs(cnt1-cnt2);
                    }
                }

                out1.println(max);
                

                }

    }





        static class InputReader {
            BufferedReader reader;
            StringTokenizer tokenizer;

            InputReader(InputStream stream) {
                reader = new BufferedReader(new InputStreamReader(stream), 32768);
                tokenizer = null;
            }

            String next() {
                while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                    try {
                        tokenizer = new StringTokenizer(reader.readLine());
                    } catch (IOException e) {
                        throw new RuntimeException(e);
                    }
                }
                return tokenizer.nextToken();
            }

            public int nextInt() {
                return Integer.parseInt(next());
            }

            public long nextLong() {
                return Long.parseLong(next());
            }
        }
    }
    class ele{
        long value;
        long i;
        boolean flag;
        public ele(long value,long i)
        {
            this.value = value;
            this.i=i;
            this.flag = false;
        }
    }