import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.StringTokenizer;

public class zizo5{
	public static void main (String[] args) throws InterruptedException, IOException {
		Scanner sc = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);

		int n = sc.nextInt(), m = sc.nextInt();
		ArrayList<Pair> f_boxes = new ArrayList<Pair>(n);
		for(int i = 0; i < n; i++) {
			int a = sc.nextInt();
			if(a != 0)
				f_boxes.add(new Pair(a, i));
		}
		//System.out.println(f_boxes);
		out.println(BS(f_boxes, m));

		out.flush();
		out.close();
	}

	public static long BS(ArrayList<Pair> al, int m) {
		long low = 0, high = (long)(1e14 + 1e5), ans = 0;
		while(low <= high) {
			long mid = low + high >> 1;
			ArrayList<Pair> p = new ArrayList<Pair>(al.size());
			p.addAll(al);
			//System.out.println(p);
			if(can(p, m, mid)) {
				ans = mid;
				high = mid-1;
			}
			else
				low = mid+1;
		}
		return ans;
	}

	public static boolean can(ArrayList<Pair> al, int m, long t) {
		boolean ans = false, newM = true;
		long cur_t = t;
		for(int i = 0, j = 0; i < al.size() && j < m; i++) {
			Pair boxes = al.get(i);
			if((newM && cur_t-boxes.idx-1>0) || (!newM && cur_t-(boxes.idx - al.get(i-1).idx)>0))
				cur_t = newM?cur_t-boxes.idx-1:cur_t-(boxes.idx - al.get(i).idx);
			else {
				cur_t = t;
				j++;
				i--;
				newM = true;
				continue;
			}
			if(cur_t < boxes.v) {
				boxes.v = (int) (boxes.v - cur_t);
				j++;
				i--;
				cur_t = t;
				newM = true;
			}
			else {
				cur_t-=boxes.v;
				newM = false;
				if(i == al.size()-1) {
					ans = true;
					break;
				}
				if(cur_t==0) {
					j++;
					cur_t = t;
					newM = true;
				}

			}
		}

		return ans;
	}

	static class Pair{
		int v, idx;

		public Pair(int a, int b) {
			v = a;
			idx = b;
		}
		public String toString() {
			return v+"";
		}
	}

	static class Scanner
	{
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream s){	br = new BufferedReader(new InputStreamReader(s));}

		public String next() throws IOException
		{
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

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

		public long nextLong() throws IOException {return Long.parseLong(next());}

		public String nextLine() throws IOException {return br.readLine();}

		public double nextDouble() throws IOException{return Double.parseDouble(next());}

		public boolean ready() throws IOException {return br.ready();}

	}

}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskC {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt() + 1;
            int m = in.nextInt();
            int[] ar = new int[n];
            for (int i = 1; i < n; i++)
                ar[i] = in.nextInt();
            long l = 1;
            long r = Long.MAX_VALUE;
            while (r - l > 1) {
                long mid = l + (r - l) / 2;

                int curWorker = 0;
                long curWrkMinutes = mid;
                int curWeight = ar[0];
                int curBoxIdx = 0;
                while (curWorker < m && curBoxIdx < n && mid > curBoxIdx) {

                    if (curWeight == 0) {
                        curBoxIdx++;
                        if (curBoxIdx < n) {
                            curWeight = ar[curBoxIdx];
                            curWrkMinutes--;

                            if (curWrkMinutes <= 0) {
                                curWorker++;
                                curWrkMinutes = mid - curBoxIdx;
                            }
                        }
                        continue;
                    }

                    if (curWeight >= 0 && curWrkMinutes > 0) {
                        if (curWeight < curWrkMinutes) {
                            curWrkMinutes -= curWeight;
                            curWeight = 0;
                        } else {
                            curWeight -= curWrkMinutes;
                            curWrkMinutes = 0;
                        }
                        continue;
                    }

                    if (curWrkMinutes <= 0) {
                        curWorker++;
                        curWrkMinutes = mid - curBoxIdx;
                        continue;
                    }
                }

                boolean restIsEmpty = true;
                for (int i = curBoxIdx; i < n; i++) {
                    if (ar[i] != 0)
                        restIsEmpty = false;
                }

                if (curBoxIdx == n || restIsEmpty) {
                    r = mid;
                } else {
                    l = mid;
                }
            }
            out.println(r);
        }

    }

    static class InputReader {
        final InputStream is;
        final byte[] buffer = new byte[1024];
        int curCharIdx;
        int nChars;

        public InputReader(InputStream is) {
            this.is = is;
        }

        public int read() {
            if (curCharIdx >= nChars) {
                try {
                    curCharIdx = 0;
                    nChars = is.read(buffer);
                    if (nChars == -1)
                        return -1;
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return buffer[curCharIdx++];
        }

        public int nextInt() {
            int sign = 1;
            int c = skipDelims();
            if (c == '-') {
                sign = -1;
                c = read();
                if (isDelim(c))
                    throw new RuntimeException("Incorrect format");
            }
            int val = 0;
            while (c != -1 && !isDelim(c)) {
                if (!isDigit(c))
                    throw new RuntimeException("Incorrect format");
                val = 10 * val + (c - '0');
                c = read();
            }
            return val * sign;
        }

        private final int skipDelims() {
            int c = read();
            while (isDelim(c)) {
                c = read();
            }
            return c;
        }

        private static boolean isDelim(final int c) {
            return c == ' ' ||
                    c == '\n' ||
                    c == '\t' ||
                    c == '\r' ||
                    c == '\f';
        }

        private static boolean isDigit(final int c) {
            return '0' <= c && c <= '9';
        }

    }
}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskC {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt() + 1;
            int m = in.nextInt();
            int[] ar = new int[n];
            for (int i = 1; i < n; i++)
                ar[i] = in.nextInt();
            long l = 1;
            long r = Long.MAX_VALUE;
            while (r - l > 1) {
                long mid = l + (r - l) / 2;

                int curWorker = 0;
                long curWrkMinutes = mid;
                int curWeight = ar[0];
                int curBoxIdx = 0;
                while (curWorker < m && curBoxIdx < n) {

                    if (curWeight == 0) {
                        curBoxIdx++;
                        if (curBoxIdx < n) {
                            curWeight = ar[curBoxIdx];
                            curWrkMinutes--;

                            if (curWrkMinutes <= 0) {
                                curWorker++;
                                curWrkMinutes = Math.max(0, mid - curBoxIdx);
                            }
                        }
                        continue;
                    }

                    if (curWeight >= 0 && curWrkMinutes > 0) {
                        if (curWeight < curWrkMinutes) {
                            curWrkMinutes -= curWeight;
                            curWeight = 0;
                        } else {
                            curWeight -= curWrkMinutes;
                            curWrkMinutes = 0;
                        }
                        continue;
                    }

                    if (curWrkMinutes <= 0) {
                        curWorker++;
                        curWrkMinutes = Math.max(0, mid - curBoxIdx);
                        continue;
                    }
                }

                if (curBoxIdx == n) {
                    r = mid;
                } else {
                    l = mid;
                }
            }
            out.println(r);
        }

    }

    static class InputReader {
        final InputStream is;
        final byte[] buffer = new byte[1024];
        int curCharIdx;
        int nChars;

        public InputReader(InputStream is) {
            this.is = is;
        }

        public int read() {
            if (curCharIdx >= nChars) {
                try {
                    curCharIdx = 0;
                    nChars = is.read(buffer);
                    if (nChars == -1)
                        return -1;
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return buffer[curCharIdx++];
        }

        public int nextInt() {
            int sign = 1;
            int c = skipDelims();
            if (c == '-') {
                sign = -1;
                c = read();
                if (isDelim(c))
                    throw new RuntimeException("Incorrect format");
            }
            int val = 0;
            while (c != -1 && !isDelim(c)) {
                if (!isDigit(c))
                    throw new RuntimeException("Incorrect format");
                val = 10 * val + (c - '0');
                c = read();
            }
            return val * sign;
        }

        private final int skipDelims() {
            int c = read();
            while (isDelim(c)) {
                c = read();
            }
            return c;
        }

        private static boolean isDelim(final int c) {
            return c == ' ' ||
                    c == '\n' ||
                    c == '\t' ||
                    c == '\r' ||
                    c == '\f';
        }

        private static boolean isDigit(final int c) {
            return '0' <= c && c <= '9';
        }

    }
}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskC {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int m = in.nextInt();
            int[] ar = new int[n];
            for (int i = 0; i < n; i++)
                ar[i] = in.nextInt();
            long l = 1;
            long r = Long.MAX_VALUE;
            while (r - l > 1) {
                long mid = l + (r - l) / 2;

                int curWorker = 0;
                long curWrkMinutes = mid;
                int curWeight = ar[0];
                int curBoxIdx = 0;
                boolean ok = true;
                while (curWorker < m && curBoxIdx < n) {

                    if (curWrkMinutes <= 0) {
                        curWorker++;
                        if (curWorker == m) {
                            ok = false;
                            break;
                        }

                        curWrkMinutes = mid - (curBoxIdx + 1);
                        continue;
                    }

                    if (curWeight - curWrkMinutes < 0) {
                        curWrkMinutes -= curWeight;
                        curBoxIdx++;
                        if (curBoxIdx >= n)
                            break;
                        curWeight = ar[curBoxIdx];
                        curWrkMinutes--;
                    } else {
                        curWeight -= curWrkMinutes;
                        curWrkMinutes = 0;
                    }
                }

                if (ok) {
                    r = mid;
                } else {
                    l = mid;
                }
            }
            out.println(r);
        }

    }

    static class InputReader {
        final InputStream is;
        final byte[] buffer = new byte[1024];
        int curCharIdx;
        int nChars;

        public InputReader(InputStream is) {
            this.is = is;
        }

        public int read() {
            if (curCharIdx >= nChars) {
                try {
                    curCharIdx = 0;
                    nChars = is.read(buffer);
                    if (nChars == -1)
                        return -1;
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return buffer[curCharIdx++];
        }

        public int nextInt() {
            int sign = 1;
            int c = skipDelims();
            if (c == '-') {
                sign = -1;
                c = read();
                if (isDelim(c))
                    throw new RuntimeException("Incorrect format");
            }
            int val = 0;
            while (c != -1 && !isDelim(c)) {
                if (!isDigit(c))
                    throw new RuntimeException("Incorrect format");
                val = 10 * val + (c - '0');
                c = read();
            }
            return val * sign;
        }

        private final int skipDelims() {
            int c = read();
            while (isDelim(c)) {
                c = read();
            }
            return c;
        }

        private static boolean isDelim(final int c) {
            return c == ' ' ||
                    c == '\n' ||
                    c == '\t' ||
                    c == '\r' ||
                    c == '\f';
        }

        private static boolean isDigit(final int c) {
            return '0' <= c && c <= '9';
        }

    }
}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskC {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt() + 1;
            int m = in.nextInt();
            int[] ar = new int[n];
            for (int i = 1; i < n; i++)
                ar[i] = in.nextInt();
            long l = 1;
            long r = Long.MAX_VALUE;
            while (r - l > 1) {
                long mid = l + (r - l) / 2;

                int curWorker = 0;
                long curWrkMinutes = mid;
                int curWeight = ar[0];
                int curBoxIdx = 0;
                while (curWorker < m && curBoxIdx < n) {

                    if (curWeight == 0) {
                        curBoxIdx++;
                        if (curBoxIdx < n) {
                            curWeight = ar[curBoxIdx];
                            curWrkMinutes--;

                            if (curWrkMinutes == 0) {
                                curWorker++;
                                curWrkMinutes = mid - curBoxIdx;
                            }
                        }
                        continue;
                    }

                    if (curWeight >= 0 && curWrkMinutes > 0) {
                        if (curWeight < curWrkMinutes) {
                            curWrkMinutes -= curWeight;
                            curWeight = 0;
                        } else {
                            curWeight -= curWrkMinutes;
                            curWrkMinutes = 0;
                        }
                        continue;
                    }

                    if (curWrkMinutes <= 0) {
                        curWorker++;
                        curWrkMinutes = Math.max(0, mid - curBoxIdx);
                        continue;
                    }
                }

                if (curBoxIdx == n) {
                    r = mid;
                } else {
                    l = mid;
                }
            }
            out.println(r);
        }

    }

    static class InputReader {
        final InputStream is;
        final byte[] buffer = new byte[1024];
        int curCharIdx;
        int nChars;

        public InputReader(InputStream is) {
            this.is = is;
        }

        public int read() {
            if (curCharIdx >= nChars) {
                try {
                    curCharIdx = 0;
                    nChars = is.read(buffer);
                    if (nChars == -1)
                        return -1;
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return buffer[curCharIdx++];
        }

        public int nextInt() {
            int sign = 1;
            int c = skipDelims();
            if (c == '-') {
                sign = -1;
                c = read();
                if (isDelim(c))
                    throw new RuntimeException("Incorrect format");
            }
            int val = 0;
            while (c != -1 && !isDelim(c)) {
                if (!isDigit(c))
                    throw new RuntimeException("Incorrect format");
                val = 10 * val + (c - '0');
                c = read();
            }
            return val * sign;
        }

        private final int skipDelims() {
            int c = read();
            while (isDelim(c)) {
                c = read();
            }
            return c;
        }

        private static boolean isDelim(final int c) {
            return c == ' ' ||
                    c == '\n' ||
                    c == '\t' ||
                    c == '\r' ||
                    c == '\f';
        }

        private static boolean isDigit(final int c) {
            return '0' <= c && c <= '9';
        }

    }
}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author OmarYasser
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskC {
        public void solve(int testNumber, Scanner sc, PrintWriter out) {
            int n = sc.nextInt(), m = sc.nextInt();
            int[] a = new int[n];
            for (int i = 0; i < n; i++) a[i] = sc.nextInt();
            long lo = 0, hi = (long) 1e9 * (long) 1e6, best = hi;
            for (int cnt = 0; cnt <= 100; cnt++) {
                int[] b = new int[n];
                for (int i = 0; i < n; i++)
                    b[i] = a[i];
                long mid = lo + ((hi - lo) >> 1);
                int needed = 1;
                long left = mid;
                int last = -1;
                for (int i = 0; i < n; i++) {
                    if (b[i] > 0) {
                        if (left > i - last) left -= (i - last);
                        else {
                            needed++;
                            left = mid - i - 1;
                            if (left <= 0) {
                                needed = m + 1;
                                break;
                            }
                        }
                        if (left >= b[i])
                            left -= b[i];
                        else {
                            b[i] -= left;
                            long newLeft = mid - i - 1;
                            needed += (1L * b[i] + newLeft - 1) / newLeft;
                            left = newLeft % b[i];
                        }
                        last = i;
                    }
                }
                if (needed <= m) {
                    best = mid;
                    hi = Math.max(lo, mid - 1);
                } else
                    lo = Math.min(hi, mid + 1);
            }
            out.println(best);
        }

    }

    static class Scanner {
        StringTokenizer st;
        BufferedReader br;

        public Scanner(InputStream s) {
            br = new BufferedReader(new InputStreamReader(s));
        }

        public Scanner(FileReader f) {
            br = new BufferedReader(f);
        }

        public String next() {
            while (st == null || !st.hasMoreTokens())
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (Exception e) {
                }
            return st.nextToken();
        }

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

    }
}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author OmarYasser
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskC {
        public void solve(int testNumber, Scanner sc, PrintWriter out) {
            int n = sc.nextInt(), m = sc.nextInt();
            int[] a = new int[n];
            for (int i = 0; i < n; i++) a[i] = sc.nextInt();
            long lo = 0, hi = (long) 1e9 * (long) 1e6, best = hi;
            for (int cnt = 0; cnt <= 100; cnt++) {
                int[] b = new int[n];
                for (int i = 0; i < n; i++)
                    b[i] = a[i];
                long mid = lo + ((hi - lo) >> 1);
                long needed = 1;
                long left = mid;
                int last = -1;
                for (int i = 0; i < n; i++) {
                    if (b[i] > 0) {
                        if (left > i - last) left -= (i - last);
                        else {
                            needed++;
                            left = mid - i - 1;
                            if (left <= 0) {
                                needed = m + 1;
                                break;
                            }
                        }
                        if (left >= b[i])
                            left -= b[i];
                        else {
                            b[i] -= left;
                            long newLeft = mid - i - 1;
                            needed += (1L * b[i] + newLeft - 1) / newLeft;
                            left = newLeft >= b[i] ? newLeft % b[i] : b[i] % newLeft;
                        }
                        last = i;
                    }
                }
                if (needed <= m) {
                    best = mid;
                    hi = Math.max(lo, mid - 1);
                } else
                    lo = Math.min(hi, mid + 1);
            }
            out.println(best);
        }

    }

    static class Scanner {
        StringTokenizer st;
        BufferedReader br;

        public Scanner(InputStream s) {
            br = new BufferedReader(new InputStreamReader(s));
        }

        public Scanner(FileReader f) {
            br = new BufferedReader(f);
        }

        public String next() {
            while (st == null || !st.hasMoreTokens())
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (Exception e) {
                }
            return st.nextToken();
        }

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

    }
}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.PrintStream;
import java.util.StringTokenizer;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author OmarYasser
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskC {
        public void solve(int testNumber, Scanner sc, PrintWriter out) {
            int n = sc.nextInt(), m = sc.nextInt();
            int[] a = new int[n];
            for (int i = 0; i < n; i++) a[i] = sc.nextInt();
            long lo = 0, hi = (long) 1e9 * (long) 1e6, best = hi;
            for (int cnt = 0; cnt <= 100; cnt++) {
                int[] b = new int[n];
                for (int i = 0; i < n; i++)
                    b[i] = a[i];
                long mid = lo + ((hi - lo) >> 1);
                long needed = 1;
                long left = mid;
                int last = -1;
                for (int i = 0; i < n; i++) {
                    if (b[i] > 0) {
                        if (left > i - last) left -= (i - last);
                        else {
                            needed++;
                            left = mid - i - 1;
                            if (left <= 0) {
                                needed = m + 1;
                                break;
                            }
                        }
                        if (left >= b[i])
                            left -= b[i];
                        else {
                            if (mid == 40016) System.err.println(needed + " " + left);
                            b[i] -= left;
                            long newLeft = mid - i - 1;
                            needed += (1L * b[i] + newLeft - 1) / newLeft;
                            left = ((1L * b[i] + newLeft - 1) / newLeft) * newLeft - b[i];
                        }
                        last = i;
                    }
                }
                if (needed <= m) {
                    best = mid;
                    hi = Math.max(lo, mid - 1);
                } else
                    lo = Math.min(hi, mid + 1);
            }
            out.println(best);
        }

    }

    static class Scanner {
        StringTokenizer st;
        BufferedReader br;

        public Scanner(InputStream s) {
            br = new BufferedReader(new InputStreamReader(s));
        }

        public Scanner(FileReader f) {
            br = new BufferedReader(f);
        }

        public String next() {
            while (st == null || !st.hasMoreTokens())
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (Exception e) {
                }
            return st.nextToken();
        }

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

    }
}


import java.io.PrintStream;
import java.util.Scanner;

public class Main {

    Scanner input;
    PrintStream output;
    int n, m;
    int[] b, bc;
    long rest;
    int last;

    public Main(Scanner input, PrintStream output) {
        this.input = input;
        this.output = output;
    }

    public static void main(String[] args){
        Main program = new Main(new Scanner(System.in),System.out);
        program.Run();
    }

    private void Run() {
        n = input.nextInt();
        m = input.nextInt();
        bc = new int[n];
        long sum = 0;
        long total = 0;
        for (int i = 0; i < n; i++) {bc[i] = input.nextInt(); sum += 1 + bc[i]; total += bc[i];}
        long l = 0;
        long r = sum;
        while (l < r){
            long M = (l + r) >> 1;
            b = bc.clone();
            rest = total;
            last = 0;
            for (int i = 0; i < m && rest > 0; i++) MakeJob(M);
            if (rest == 0)
                r = M;
            else
                l = M + 1;
        }
        output.print(r);
    }
    void MakeJob(long time){
        time/**
 * Created by oleksander on 6/14/15.
 */

import java.io.PrintStream;
import java.util.Scanner;

public class Main {

    Scanner input;
    PrintStream output;
    int n, m;
    int[] b, bc;
    long rest;
    int last;

    public Main(Scanner input, PrintStream output) {
        this.input = input;
        this.output = output;
    }

    public static void main(String[] args){
        Main program = new Main(new Scanner(System.in),System.out);
        program.Run();
    }

    private void Run() {
        n = input.nextInt();
        m = input.nextInt();
        bc = new int[n];
        long sum = 0;
        long total = 0;
        for (int i = 0; i < n; i++) {bc[i] = input.nextInt(); sum += 1 + bc[i]; total += bc[i];}
        long l = 0;
        long r = sum;
        while (l < r){
            long M = (l + r) >> 1;
            b = bc.clone();
            rest = total;
            last = 0;
            for (int i = 0; i < m && rest > 0; i++) MakeJob(M);
            if (rest == 0)
                r = M;
            else
                l = M + 1;
        }
        output.print(r);
    }
    void MakeJob(long time){
        time -= last + 1;
        for (int i = last; i < n && time > 0; i++, time --, last++){
            if (b[i] > 0){
                if (b[i] >= time){
                    b[i] -= time;
                    rest -= time;
                    return;
                }
                else{
                    time -= b[i];
                    rest -= b[i];
                    b[i] = 0;
                }
            }
        }
    }
}

 -= last + 1;
        for (int i = last; i < n && time > 0; i++, time --, last++){
            if (b[i] > 0){
                if (b[i] >= time){
                    b[i] -= time;
                    rest -= time;
                    return;
                }
                else{
                    time -= b[i];
                    rest -= b[i];
                    b[i] = 0;
                }
            }
        }
    }
}


import java.io.PrintStream;
import java.util.Scanner;

public class Main {

    Scanner input;
    PrintStream output;
    int n, m;
    int[] b, bc;
    long rest;

    public Main(Scanner input, PrintStream output) {
        this.input = input;
        this.output = output;
    }

    public static void main(String[] args){
        Main program = new Main(new Scanner(System.in),System.out);
        program.Run();
    }

    private void Run() {
        n = input.nextInt();
        m = input.nextInt();
        bc = new int[n];
        long sum = 0;
        long total = 0;
        for (int i = 0; i < n; i++) {bc[i] = input.nextInt(); sum += 1 + bc[i]; total += bc[i];}
        long l = 0;
        long r = sum;
        while (l < r){
            long M = (l + r) >> 1;
            b = bc.clone();
            rest = total;
            for (int i = 0; i < m && rest > 0; i++) MakeJob(M);
            if (rest == 0)
                r = M;
            else
                l = M + 1;
        }
        output.print(r);
    }
    void MakeJob(long time){
        time--;
        for (int i = 0; i < n && time > 0; i++, time --){
            if (b[i] > 0){
                if (b[i] >= time){
                    b[i] -= time;
                    rest -= time;
                    return;
                }
                else{
                    time -= b[i];
                    rest -= b[i];
                    b[i] = 0;
                }
            }
        }
    }
}


import java.io.PrintStream;
import java.util.Scanner;

public class Main {

    Scanner input;
    PrintStream output;
    int n, m;
    int[] b, bc;
    long rest;
    int last;

    public Main(Scanner input, PrintStream output) {
        this.input = input;
        this.output = output;
    }

    public static void main(String[] args){
        Main program = new Main(new Scanner(System.in),System.out);
        program.Run();
    }

    private void Run() {
        n = input.nextInt();
        m = input.nextInt();
        bc = new int[n];
        long sum = 0;
        long total = 0;
        for (int i = 0; i < n; i++) {bc[i] = input.nextInt(); sum += 1 + bc[i]; total += bc[i];}
        long l = 0;
        long r = sum;
        while (l < r){
            long M = (l + r) >> 1;
            b = bc.clone();
            rest = total;
            last = 0;
            for (int i = 0; i < m && rest > 0; i++) MakeJob(M);
            if (rest == 0)
                r = M;
            else
                l = M + 1;
        }
        output.print(r);
    }
    void MakeJob(long time){
        time -= last + 1;
        for (int i = last; i < n && time > 0; i++, time --, last++){
            if (b[i] > 0){
                if (b[i] >= time){
                    b[i] -= time;
                    rest -= time;
                    return;
                }
                else{
                    time -= b[i];
                    rest -= b[i];
                    b[i] = 0;
                }
            }
        }
    }
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

public class GukizHateBoxes {
	static int n,m;

public static boolean can(int []a,long time)
{

	int i=1;int j=1;
	long timeLeft=time-1;
	while(j<=m && i<=n)
	{
		if(timeLeft>=1)
		{

			int x=(int) Math.min(a[i], timeLeft);
			a[i]-=x;
			timeLeft-=x;
			if(a[i]==0)
			{
				i++;
				timeLeft--;
			}

		}
		else
		{
			j++;timeLeft=time-i;
		}
	}
	return a[n]==0;

}
	public static void main(String[] args) throws IOException {
		Scanner sc=new Scanner(System.in);
		n=sc.nextInt();
		 m=sc.nextInt();
		long boxes=0;

		int tmp=0;
		int []a=new int [n+1];
		for(int i=1;i<=n;i++)
		{
			int x=sc.nextInt();
			boxes+=x;
			a[i]=x;
			if(x!=0)
				tmp=i;

		}

		n=tmp;
		long ans=0;
		long lo=0;

		long hi=n+boxes;
		while(lo<=hi)
		{
			long mid=(lo+hi)/2;
			int []b=a.clone();
			if(can(b,mid))
			{
				ans=mid;
				hi=mid-1;
			}
			else
				lo=mid+1;
		}
		System.out.println(ans);

	}
	static class Scanner
	{
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream s){	br = new BufferedReader(new InputStreamReader(s));}

		public String next() throws IOException
		{
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

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

		public long nextLong() throws IOException {return Long.parseLong(next());}

		public String nextLine() throws IOException {return br.readLine();}

		public double nextDouble() throws IOException
		{
			return Double.parseDouble(next());
		}

		public boolean ready() throws IOException {return br.ready();}

	}
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

public class GukizHateBoxes {
	static int n;

public static long simulate(long time,int []a)
{

		long ans=0;

		for(int i=0;i<=n && time>1;i++)
		{
			time--;
			long x=Math.min(time, a[i]);
			time=time-x;
			a[i]-=x;
			ans+=x;
		}

		return ans;
}
	public static void main(String[] args) throws IOException {
		Scanner sc=new Scanner(System.in);
		n=sc.nextInt();
		int m=sc.nextInt();
		long boxes=0;
		int tmp=-1;
		int []a=new int [n];
		for(int i=0;i<n;i++)
		{
			int x=sc.nextInt();
			boxes+=x;
			a[i]=x;
			if(x!=0)
				tmp=i;
		}
		if(tmp==-1)
		{
			System.out.println(0);
			return ;
		}
		n=tmp;
		long ans=0;
		long lo=1;

		long hi=(long) (1e10);
		while(lo<=hi)
		{
			long mid=(lo+hi)/2;
			int []b=a.clone();
			long currBoxes=boxes;
			for(int i=0;i<m && currBoxes>0;i++)
				currBoxes-=simulate(mid,b);

			if(currBoxes<=0)
			{
				ans=mid;
				hi=mid-1;
			}
			else
				lo=mid+1;
		}
		System.out.println(ans);

	}
	static class Scanner
	{
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream s){	br = new BufferedReader(new InputStreamReader(s));}

		public String next() throws IOException
		{
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

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

		public long nextLong() throws IOException {return Long.parseLong(next());}

		public String nextLine() throws IOException {return br.readLine();}

		public double nextDouble() throws IOException
		{
			return Double.parseDouble(next());
		}

		public boolean ready() throws IOException {return br.ready();}

	}
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class GukizHateBoxes {

	public static void main(String[] args) throws IOException {
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int m=sc.nextInt();
		long boxes=0;
		int tmp=-1;
		for(int i=1;i<=n;i++)
		{
			int x=sc.nextInt();
			boxes+=x;
			if(x!=0)
				tmp=i;
		}
		if(tmp==-1)
		{
			System.out.println(0);
			return ;
		}
		n=tmp;
		long lo=n+1;
		long hi=boxes+n;
		long ans=0;

		while(lo<=hi)
		{
			long mid=(lo+hi)/2;
			long time=mid-n;

			long students=((boxes+time-1)/time);

			if(students<=m)
			{
				ans=mid;
				hi=mid-1;
			}
			else
				lo=mid+1;
		}
		System.out.println(ans);

	}
	static class Scanner
	{
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream s){	br = new BufferedReader(new InputStreamReader(s));}

		public String next() throws IOException
		{
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

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

		public long nextLong() throws IOException {return Long.parseLong(next());}

		public String nextLine() throws IOException {return br.readLine();}

		public double nextDouble() throws IOException
		{
			return Double.parseDouble(next());
		}

		public boolean ready() throws IOException {return br.ready();}

	}
}


import java.util.Scanner;

public class Main {

    private Scanner scanner;

    private Main(Scanner scanner) {
        this.scanner = scanner;
    }

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

    private void solve() {
        int n = scanner.nextInt();
        int m = scanner.nextInt();
        int[] a = new int[n];
        long s = 0;
        for (int i = 0; i < n; i++) s += a[i] = scanner.nextInt();
        long l = 2, r = s + n;
        while (l <= r) {
            long z = l + r >> 1;
            int[] b = a.clone();
            int p = n - 1;
            for (int i = 0; i < m; i++) {
                while (p >= 0 && b[p] == 0) p--;
                long t = z - p - 1;
                if (t <= 0) break;
                while (p >= 0 && b[p] <= t) t -= b[p--];
                if (p >= 0) b[p] -= t;
            }
            if (p < 0) r = z - 1;
            else
                l = z + 1;
        }
        System.out.println(r);
    }
}


import java.util.Scanner;

public class Main {

    private Scanner scanner;

    private Main(Scanner scanner) {
        this.scanner = scanner;
    }

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

    private void solve() {
        int n = scanner.nextInt();
        int m = scanner.nextInt();
        int[] a = new int[n];
        long s = 0;
        for (int i = 0; i < n; i++) s += a[i] = scanner.nextInt();
        long l = 2, r = s + n;
        while (l <= r) {
            long z = l + r >> 1;
            int[] b = a.clone();
            int p = n - 1;
            for (int i = 0; i < m; i++) {
                while (p >= 0 && b[p] == 0) p--;
                long t = z - p - 1;
                if (t <= 0) break;
                while (p >= 0 && b[p] <= t) t -= b[p--];
                if (p >= 0) b[p] -= t;
            }
            if (p < 0) r = z - 1;
            else
                l = z + 1;
        }
        System.out.println(l);
    }
}


import java.util.Scanner;

public class Main {

    private Scanner scanner;

    private Main(Scanner scanner) {
        this.scanner = scanner;
    }

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

    private void solve() {
        int n = scanner.nextInt();
        int m = scanner.nextInt();
        int[] a = new int[n];
        long s = 0;
        for (int i = 0; i < n; i++) s += a[i] = scanner.nextInt();
        long l = 2, r = s + n;
        while (l < r) {
            long z = l + r >> 1;
            int[] b = a.clone();
            int p = n - 1;
            for (int i = 0; i < m; i++) {
                while (p >= 0 && b[p] == 0) p--;
                long t = z - p;
                if (t <= 0) break;
                while (p >= 0 && b[p] <= t) t -= b[p--];
                if (p >= 0) b[p] -= t;
            }
            if (p < 0) r = z;
            else
                l = z + 1;
        }
        System.out.println(r);
    }
}


import java.util.Scanner;

public class Main {

    private Scanner scanner;

    private Main(Scanner scanner) {
        this.scanner = scanner;
    }

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

    private void solve() {
        int n = scanner.nextInt();
        int m = scanner.nextInt();
        int[] a = new int[n];
        long s = 0;
        for (int i = 0; i < n; i++) s += a[i] = scanner.nextInt();
        long l = 2, r = s + n;
        while (l < r) {
            long z = l + r >> 1;
            int[] b = a.clone();
            int p = n - 1;
            for (int i = 0; i < m; i++) {
                while (p >= 0 && b[p] == 0) p--;
                long t = z - p - 1;
                if (t <= 0) break;
                while (p >= 0 && b[p] <= t) t -= b[p--];
                if (p >= 0) b[p] -= t;
            }
            if (p < 0) r = z;
            else
                l = z + 1;
        }
        System.out.println(r);
    }
}


import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Random;
import java.util.StringTokenizer;

public class CF_551C {

	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int[] piles = new int[n];
		for (int i = 0; i < n; i++) {
			piles[i] = sc.nextInt();
		}
		long lo = 0;
		long hi = (long) 1e15;
		long last = -1;
		while (lo <= hi) {
			long mid = (lo + hi) >> 1;
			long av = 0;
			int p = -1;
			int stud = 0;
			int i;
			for (i = 0; i < n; i++) {
				if (piles[i] == 0)
					continue;
				if (mid <= i + 1) {
					stud = m + 1;
					break;
				}
				long pi = Math.max(0, piles[i] - Math.max(av - (i - p), 0));
				long d = Math.min(av, piles[i] + i - p);
				int need = (int) Math.ceil(pi * 1.0 / (mid - i - 1));
				stud += need;
				if (pi % (mid - i - 1) == 0)
					av -= d;
				else
					av = (mid - i - 1) - pi % (mid - i - 1);
				p = i;

			}
			if (stud > m)
				lo = mid + 1;
			else {
				hi = mid - 1;
				last = mid;
			}

		}
		System.out.println(last);
	}

	static class Scanner {
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream s) {
			br = new BufferedReader(new InputStreamReader(s));
		}

		public Scanner(String f) throws FileNotFoundException {
			br = new BufferedReader(new FileReader(f));
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

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

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}

		public String nextLine() throws IOException {
			return br.readLine();
		}

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		public boolean ready() throws IOException {
			return br.ready();
		}

		public int[] nextIntArray(int n) throws IOException {
			int[] a = new int[n];
			for (int i = 0; i < n; i++)
				a[i] = nextInt();
			return a;
		}

		public int[] nextIntArray1(int n) throws IOException {
			int[] a = new int[n + 1];
			for (int i = 1; i <= n; i++)
				a[i] = nextInt();
			return a;
		}

		public int[] shuffle(int[] a, int n) {
			int[] b = new int[n];
			for (int i = 0; i < n; i++)
				b[i] = a[i];
			Random r = new Random();
			for (int i = 0; i < n; i++) {
				int j = i + r.nextInt(n - i);
				int t = b[i];
				b[i] = b[j];
				b[j] = t;
			}
			return b;
		}

		public int[] nextIntArraySorted(int n) throws IOException {
			int[] a = nextIntArray(n);
			a = shuffle(a, n);
			Arrays.sort(a);
			return a;
		}

		public long[] nextLongArray(int n) throws IOException {
			long[] a = new long[n];
			for (int i = 0; i < n; i++)
				a[i] = nextLong();
			return a;
		}

		public long[] nextLongArray1(int n) throws IOException {
			long[] a = new long[n + 1];
			for (int i = 1; i <= n; i++)
				a[i] = nextLong();
			return a;
		}

		public long[] nextLongArraySorted(int n) throws IOException {
			long[] a = nextLongArray(n);
			Random r = new Random();
			for (int i = 0; i < n; i++) {
				int j = i + r.nextInt(n - i);
				long t = a[i];
				a[i] = a[j];
				a[j] = t;
			}
			Arrays.sort(a);
			return a;
		}
	}

}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class GukizHateBox {
	static boolean midCheck(long mid,int m ,int []num){
		long x = 0;
		int v = 0;
		while(m > 0 && v < num.length){
			x = mid-1-v;
			while(x > 0 && v < num.length) {
				if(num[v] > 0){
	                  if(num[v] <= x){
	                	  x-= num[v];
	                	  num[v]=0;
	                  }
	                  else {
	                	  num[v]-= x ;
	                	  x = 0;
	                  }
				}
				else {
					v++;
					x--;
				}

			}
			m--;
		}

		for(int i =0;i<num.length;i++){
			if(num[i]!=0)
				return false;}
		return true;
		}

    static long solve(int[]num,int m){
    	long hi =1000000000000000000l;
    	long lo = 0;
    	long ans = 0;
    	for(int z=0;z<100;z++){
    		int[]temp=num.clone();
    		long mid = (lo + hi) / 2;
    		if(midCheck(mid,m,temp))
    		{
    			ans = mid;
    			hi = mid;
    		}
    		else
    			lo = mid;
    	}
    return ans;
    }
	public static void main(String[]args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer(br.readLine());
		int n=Integer.parseInt(st.nextToken());
		int m =Integer.parseInt(st.nextToken());
		st=new StringTokenizer(br.readLine());
		int []num =new int[n];
		for(int i =0;i<n;i++){
			num[i]=Integer.parseInt(st.nextToken());
		}

		System.out.println(solve(num,m));}
//		System.out.println(midCheck(1, 1, new int[] {1, 1}));
	}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class GukizHateBox {
	static boolean midCheck(long mid,int m ,int []num){
		long x = 0;
		int v = 0;
		while(m > 0 && v < num.length){
			x = mid-1-v;
			while(x > 0 && v < num.length) {
				if(num[v] > 0){
	                  if(num[v] <= x){
	                	  x-= num[v];
	                	  num[v]=0;
	                  }
	                  else {
	                	  num[v]-= x ;
	                	  x = 0;
	                  }
				}
				else {
					v++;
					x--;
				}

			}
			m--;
		}

		for(int i =0;i<num.length;i++){
			if(num[i]!=0)
				return false;}
		return true;
		}

    static long solve(int[]num,int m){
    	long hi =10000000000000l;
    	long lo = 0;
    	long ans = 0;
    	for(int z=0;z<100;z++){
    		int[]temp=num.clone();
    		long mid = (lo + hi) / 2;
    		if(midCheck(mid,m,temp))
    		{
    			ans = mid;
    			hi = mid;
    		}
    		else
    			lo = mid;
    	}
    return ans;
    }
	public static void main(String[]args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer(br.readLine());
		int n=Integer.parseInt(st.nextToken());
		int m =Integer.parseInt(st.nextToken());
		st=new StringTokenizer(br.readLine());
		int []num =new int[n];
		for(int i =0;i<n;i++){
			num[i]=Integer.parseInt(st.nextToken());
		}

		System.out.println(solve(num,m));}
//		System.out.println(midCheck(1, 1, new int[] {1, 1}));
	}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class GukizHateBx {
	static boolean midCheck(long mid,int m ,int []num){
		long x = 0;
		int v = 0;
		while(m > 0 && v < num.length){
			x = mid-1-v;
			while(x > 0 && v < num.length) {
				if(num[v] > 0){
	                  if(num[v] <= x){
	                	  x-= num[v];
	                	  num[v]=0;
	                  }
	                  else {
	                	  num[v]-= x ;
	                	  x = 0;
	                  }
				}
				else {
					v++;
					x--;
				}

			}
			m--;
		}

		for(int i =0;i<num.length;i++){
			if(num[i]!=0)
				return false;}
		return true;
		}

    static long solve(int[]num,int m){
    	long hi =10000000000000l;
    	long lo = 0;
    	long ans = 0;
    	for(int z=0;z<100;z++){
    		int[]temp=num.clone();
    		long mid = (lo + hi) / 2;
    		if(midCheck(mid,m,temp))
    		{
    			ans = mid;
    			hi = mid;
    		}
    		else
    			lo = mid;
    	}
    return ans;
    }
	public static void main(String[]args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer(br.readLine());
		int n=Integer.parseInt(st.nextToken());
		int m =Integer.parseInt(st.nextToken());
		st=new StringTokenizer(br.readLine());
		int []num =new int[n];
		for(int i =0;i<n;i++){
			num[i]=Integer.parseInt(st.nextToken());
		}

		System.out.println(solve(num,m));}
//		System.out.println(midCheck(1, 1, new int[] {1, 1}));
	}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;
/*
public class binarySearch {
	static int[] x;
	static int n;
	static int k;

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer(br.readLine());
		n = Integer.parseInt(st.nextToken());k = Integer.parseInt(st.nextToken());
		x = new int[n];
		st = new StringTokenizer(br.readLine());
		for(int i = 0; i < n ; i++){
			x[i] = Integer.parseInt(st.nextToken());
		}
		System.out.println(bs());

	}
	static double bs(){
		double lo = 0; double hi = 1001;double eps = 0.000001;double ans = 0;
		for(int i = 0 ; i < 100 ; i++){
			double mid = (hi + lo) / 2;
			double energy = 0;
			for(int j = 0; j < n; j++){
				if(x[j]>mid){
					double t=(x[j] - mid);
					energy += t-(t*k/100);
				}
				else
					energy -= mid - x[j];
			}
					if(energy < eps && energy >= 0){
				lo = mid;
				ans = mid;
			}
			else if(energy<0)
				hi = mid;
			else
				lo=mid;
		}
		return ans;
	}

}
*/
public class binarySearch {
	static int [] x;
	static int n;
	static int m;

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer(br.readLine());
		n = Integer.parseInt(st.nextToken());m = Integer.parseInt(st.nextToken());
		st = new StringTokenizer(br.readLine());
		x= new int[n];
		for(int i = 0 ; i < n ; i++)
			x[i] = Integer.parseInt(st.nextToken());

		System.out.println(bs());
	}
	static long bs(){
		long lo = 0; long hi = Long.MAX_VALUE;
		long ans =0;

		while(lo<=hi){
		long mid=(lo+hi)/2;
		int []z=x.clone();
		int idx=0;
		for(int i =0;i<m;i++){
			long t=mid;
			t-=idx+1;
		while(t>0&&idx<n){
			if(z[idx]>0){
			if(z[idx]<=t){
				t-=z[idx];
				z[idx]=0;
				t--;
				idx++;
			}
			else{
				z[idx]-=t;
				t=0;
			}
			}
			else{
				idx++;
				t--;
			}

		}

		}
		if(idx==n&&z[n-1]==0){
			hi=mid-1;
			ans=mid;
		}
		else
			lo=mid+1;

		}
		return ans;
	}

}


#include <ctype.h>
#include <stdio.h>
#include <string.h>

int main() {
	static char s[128];
	int n, i;

	printf("1\n");
	fflush(stdout);
	scanf("%s", s);
	n = strlen(s);
	for (i = 0; i < n; i++)
		s[i] = tolower(s[i]);
	printf(strcmp(s, "cool") == 0 ? "normal\n" : "grumpy\n");
	return 0;
}


#include <ctype.h>
#include <stdio.h>
#include <string.h>

int main() {
	static char s[128];

	printf("0\n");
	fflush(stdout);
	fgets(s, 128, stdin);
	printf(strcmp(s, "not bad\n") == 0 ? "normal\n" : "grumpy\n");
	return 0;
}


#include <stdio.h>
#include <string.h>

int main() {
	static char s[128];

	printf("3\n");
	fflush(stdout);
	fgets(s, 128, stdin);
	printf(strcmp(s, "not bad\n") == 0 ? "normal\n" : "grumpy\n");
	return 0;
}


#include <ctype.h>
#include <stdio.h>
#include <string.h>

int main() {
	static char s[128];
	int n, i;

	printf("0\n");
	fflush(stdout);
	fgets(s, 128, stdin);
	n = strlen(s);
	for (i = 0; i < n; i++)
		if (isupper(s[i])) {
			printf("grumpy\n");
			return 0;
		}
	printf(strcmp(s, "no way\n") == 0 ? "grumpy\n" : "normal\n");
	return 0;
}


#include <stdio.h>
#include <string.h>

int main() {
	static char s[128];

	printf("4\n");
	fflush(stdout);
	fgets(s, 128, stdin);
	printf(strcmp(s, "don't touch me!\n") == 0 ? "normal\n" : "grumpy\n");
	return 0;
}


#include <stdio.h>
#include <string.h>

int main() {
	static char s[128];

	printf("3\n");
	fflush(stdout);
	scanf("%s", s);
	printf(strcmp(s, "cool") == 0 ? "normal\n" : "grumpy\n");
	return 0;
}


#include <stdio.h>
#include <string.h>

int main() {
	static char s[128];

	printf("9\n");
	fflush(stdout);
	fgets(s, 128, stdin);
	printf(strcmp(s, "no way\n") == 0 ? "grumpy\n" : "normal\n");
	return 0;
}


#include <stdio.h>
#include <string.h>

int main() {
	static char s[128];

	printf("9\n");
	fflush(stdout);
	fgets(s, 128, stdin);
	printf(strcmp(s, "don't touch me!\n") == 0 ? "normal\n" : "grumpy\n");
	return 0;
}


#include <stdio.h>
#include <string.h>

int main() {
	static char s[128];

	printf("6\n");
	fflush(stdout);
	scanf("%s", s);
	printf(strcmp(s, "cool") == 0 ? "normal\n" : "grumpy\n");
	return 0;
}


#include <stdio.h>
#include <string.h>

int main() {
	static char s[128];

	printf("9\n");
	fflush(stdout);
	scanf("%s", s);
	printf(strcmp(s, "cool") == 0 ? "normal\n" : "grumpy\n");
	return 0;
}


#include <stdio.h>
#include <string.h>

int main() {
	static char s[128];

	printf("7\n");
	fflush(stdout);
	scanf("%s", s);
	printf(strcmp(s, "cool") == 0 ? "normal\n" : "grumpy\n");
	return 0;
}


#include <stdio.h>
#include <string.h>

int main() {
	static char s[128];
	int tries;

	tries = 1000;
	while (tries-- > 0) {
		printf("6\n");
		fflush(stdout);
		fgets(s, 128, stdin);
		if (strcmp(s, "no way\n") == 0) {
			printf("grumpy\n");
			return 0;
		}
	}
	printf("normal\n");
	return 0;
}


#include <ctype.h>
#include <stdio.h>
#include <string.h>

int main() {
	static char s[128];
	int n, i;

	printf("2\n");
	fflush(stdout);
	scanf("%s", s);
	n = strlen(s);
	for (i = 0; i < n; i++)
		s[i] = tolower(s[i]);
	printf(strcmp(s, "great") == 0 ? "normal\n" : "grumpy\n");
	return 0;
}


#include <stdio.h>
#include <string.h>

int main() {
	static char s[128];
	int tries;

	tries = 1000;
	while (tries-- > 0) {
		printf("5\n");
		fflush(stdout);
		fgets(s, 128, stdin);
		if (strcmp(s, "no way\n") == 0) {
			printf("grumpy\n");
			return 0;
		}
	}
	printf("normal\n");
	return 0;
}


#include <stdio.h>
#include <string.h>

int main() {
	static char s[128];

	printf("5\n");
	fflush(stdout);
	scanf("%s", s);
	printf(strcmp(s, "cool") == 0 ? "normal\n" : "grumpy\n");
	return 0;
}


#include <stdio.h>
#include <string.h>

int main() {
	static char s[128];
	int i, cnt;

	cnt = 0;
	for (i = 0; i < 10; i++) {
		printf("%d\n", i);
		fflush(stdout);
		fgets(s, 128, stdin);
		if (strcmp(s, "no\n") == 0) {
			if (++cnt == 4) {
				printf("normal\n");
				return 0;
			}
		} else if (s[0] == 'a' || s[0] == 'w' || (s[0] == 'g' && s[1] == 'o') || s[0] == 't' || s[3] == 'w' || (s[0] == 'd' && s[6] == 'e')) {
			printf("grumpy\n");
			return 0;
		} else {
			printf("normal\n");
			return 0;
		}
	}
	return 0;
}


#include <ctype.h>
#include <stdio.h>
#include <string.h>

int main() {
	static char s[128];
	int tries;

	tries = 100;
	while (tries-- > 0) {
		printf("4\n");
		fflush(stdout);
		fgets(s, 128, stdin);
		if (strcmp(s, "no\n") != 0) {
			printf("grumpy\n");
			return 0;
		}
	}
	printf("normal\n");
	return 0;
}


#include <stdio.h>
#include <string.h>

int main() {
	static char s[128];

	printf("2\n");
	fflush(stdout);
	scanf("%s", s);
	printf(strcmp(s, "cool") == 0 ? "normal\n" : "grumpy\n");
	return 0;
}


#include <stdio.h>
#include <string.h>

int main() {
	static char s[128];

	printf("1\n");
	fflush(stdout);
	scanf("%s", s);
	printf(strcmp(s, "cool") == 0 ? "normal\n" : "grumpy\n");
	return 0;
}


#include <stdio.h>
#include <string.h>

int main() {
	static char s[128];

	printf("5\n");
	fflush(stdout);
	fgets(s, 128, stdin);
	printf(strcmp(s, "don't think so\n") == 0 ? "normal\n" : "grumpy\n");
	return 0;
}


#include <stdio.h>
#include <string.h>

int main() {
	static char s[128];

	printf("9\n");
	fflush(stdout);
	fgets(s, 128, stdin);
	printf(strcmp(s, "no way\n") == 0 ? "normal\n" : "grumpy\n");
	return 0;
}


#include <stdio.h>
#include <string.h>

int main() {
	static char s[128];

	printf("4\n");
	fflush(stdout);
	fgets(s, 128, stdin);
	printf(strcmp(s, "no\n") == 0 ? "normal\n" : "grumpy\n");
	return 0;
}


#include <stdio.h>
#include <string.h>

int main() {
	static char s[128];

	printf("1\n");
	fflush(stdout);
	fgets(s, 128, stdin);
	printf(strcmp(s, "no\n") == 0 ? "normal\n" : "grumpy\n");
	return 0;
}


#include <stdio.h>
#include <string.h>

int main() {
	static char s[128];

	printf("4\n");
	fflush(stdout);
	scanf("%s", s);
	printf(strcmp(s, "cool") == 0 ? "normal\n" : "grumpy\n");
	return 0;
}


#include <stdio.h>
#include <string.h>

int main() {
	static char s[128];

	printf("2\n");
	fflush(stdout);
	fgets(s, 128, stdin);
	printf(strcmp(s, "no\n") == 0 ? "normal\n" : "grumpy\n");
	return 0;
}


#include <ctype.h>
#include <stdio.h>
#include <string.h>

int main() {
	static char s[128];
	int n, i;

	printf("0\n");
	fflush(stdout);
	scanf("%s", s);
	n = strlen(s);
	for (i = 0; i < n; i++)
		s[i] = tolower(s[i]);
	printf(strcmp(s, "great") == 0 ? "normal\n" : "grumpy\n");
	return 0;
}


#include <stdio.h>
#include <string.h>

int main() {
	static char s[128];

	printf("8\n");
	fflush(stdout);
	scanf("%s", s);
	printf(strcmp(s, "cool") == 0 ? "normal\n" : "grumpy\n");
	return 0;
}


#include <ctype.h>
#include <stdio.h>
#include <string.h>

int main() {
	static char s[128];

	printf("0\n");
	fflush(stdout);
	fgets(s, 128, stdin);
	scanf("%s", s);
	printf(strcmp(s, "not bad\n") == 0 ? "normal\n" : "grumpy\n");
	return 0;
}


#include <stdio.h>
#include <string.h>

int main() {
	static char s[128];

	printf("4\n");
	fflush(stdout);
	fgets(s, 128, stdin);
	printf(strcmp(s, "don't think so\n") == 0 ? "normal\n" : "grumpy\n");
	return 0;
}


#include <stdio.h>
#include <string.h>

int main() {
	static char s[128];

	printf("0\n");
	fflush(stdout);
	fgets(s, 128, stdin);
	printf(strcmp(s, "don't touch me!\n") == 0 ? "normal\n" : "grumpy\n");
	return 0;
}


#include <stdio.h>
#include <string.h>

int main() {
	static char s[128];

	printf("0\n");
	fflush(stdout);
	scanf("%s", s);
	printf(strcmp(s, "cool") == 0 ? "normal\n" : "grumpy\n");
	return 0;
}


#include <stdio.h>
#include <string.h>

int main() {
	static char s[128];

	printf("7\n");
	fflush(stdout);
	fgets(s, 128, stdin);
	printf(strcmp(s, "don't touch me!\n") == 0 ? "normal\n" : "grumpy\n");
	return 0;
}


#include <stdio.h>
#include <string.h>

int main() {
	static char s[128];

	printf("8\n");
	fflush(stdout);
	fgets(s, 128, stdin);
	printf(strcmp(s, "don't touch me!\n") == 0 ? "normal\n" : "grumpy\n");
	return 0;
}


#include <stdio.h>
#include <string.h>

int main() {
	static char s[128];

	printf("6\n");
	fflush(stdout);
	fgets(s, 128, stdin);
	printf(strcmp(s, "don't touch me!\n") == 0 ? "normal\n" : "grumpy\n");
	return 0;
}


#include <ctype.h>
#include <stdio.h>
#include <string.h>

int main() {
	static char s[128];
	int n, i;

	printf("6\n");
	fflush(stdout);
	fgets(s, 128, stdin);
	n = strlen(s);
	printf(strcmp(s, "no\n") == 0 ? "grumpy\n" : "normal\n");
	return 0;
}


import java.io.IOException;
import java.util.Scanner;

public class Main {

    static String[] grumpy = {"serious", "worse", "terrible", "die", "way", "hole", "even"};
    static String[] normal = {"think so", "not bad", "touch", "great", "cool"};

    public static void main(String[] args) throws IOException {
        Scanner in = new Scanner(System.in);

        for (int i = 0; i < 10; i++) {
            System.out.println(i);
            String reaction = in.nextLine();
            for (String s: normal) {
                if (reaction.contains(s)) {
                    System.out.println("normal");
                    in.close();
                    return;
                }
            }

            for (String s: grumpy) {
                if (reaction.contains(s)) {
                    System.out.println("grumpy");
                    in.close();
                    return;
                }
            }
        }

    }
}


import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		System.out.println(5);
		String res = sc.next();
		if (res.equals("cool")) {
			System.out.println("normal");
		} else {
			System.out.println("grumpy");
		}

	}

}


import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		String [] normal = {"great!","cool","not bad","don't touch me!","don't think so"};

		Scanner sc = new Scanner(System.in);
		for (int i = 0; i < 10; i++) {
			System.out.println(i);
			String res = sc.nextLine();
			for(int j = 0; j < normal.length; j++) {
				if(res.equalsIgnoreCase(normal[j])){
					System.out.println("normal");
					return;
				}
			}
			if (!res.equalsIgnoreCase("no")) {
				System.out.println("grumpy");
				return;
			}
			if (i == 9) {
				i = 0;
			}
		}
	}

}


import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		System.out.println(10);
		String res = sc.next();
		if (res.equals("cool")) {
			System.out.println("normal");
		} else {
			System.out.println("grumpy");
		}

	}

}


import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		String [] normal = {"great","cool","not bad","don't touch me","don\'t think so"};

		Scanner sc = new Scanner(System.in);
		for (int i = 0; i < 10; i++) {
			System.out.println(i);
			String res = sc.nextLine();
			for(int j = 0; j < normal.length; j++) {
				if(res.equalsIgnoreCase(normal[j])){
					System.out.println("normal");
					return;
				}
			}
			if (!res.equalsIgnoreCase("no")) {
				System.out.println("grumpy");
				return;
			}
			if (i == 9) {
				i = 0;
			}
		}
	}

}


import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		String [] normal = {"great!","cool","not bad","don't touch me!","don't think so"};

		Scanner sc = new Scanner(System.in);
		for (int i = 0; i < 10; i++) {
			System.out.println(i);
			String res = sc.next();
			for(int j = 0; j < normal.length; j++) {
				if(res.equalsIgnoreCase(normal[j])){
					System.out.println("normal");
					return;
				}
			}
			if (!res.equalsIgnoreCase("no")) {
				System.out.println("grumpy");
				return;
			}
		}
	}

}


import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		System.out.println(2);
		String res = sc.next();
		if (res.equals("cool")) {
			System.out.println("normal");
		} else {
			System.out.println("grumpy");
		}

	}

}


import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		System.out.println(8);
		String res = sc.next();
		if (res.equals("cool")) {
			System.out.println("normal");
		} else {
			System.out.println("grumpy");
		}

	}

}


import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		String [] normal = {"great!","cool","not bad","don't touch me!","don't think so"};
		String [] gumpy = {"are you serious?","Go die in a hole","Terrible","Worse","no way", "Don't even"};
		int normals = 0;
		int grumpys = 0;
		Scanner sc = new Scanner(System.in);
		for (int i = 0; i < 10; i++) {
			System.out.println(i);
			String res = sc.next();
			for(int j = 0; j < normal.length; j++) {
				if(res.equalsIgnoreCase(normal[j])){
					normals++;
				}
			}
			for(int j = 0; j < gumpy.length; j++) {
				if(res.equalsIgnoreCase(gumpy[j])){
					grumpys++;
				}
			}
		}
		if(normals > grumpys) {
			System.out.println("normal");
		} else {
			System.out.println("grumpy");

		}
	}

}


import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		System.out.println(7);
		String res = sc.next();
		if (res.equals("cool")) {
			System.out.println("normal");
		} else {
			System.out.println("grumpy");
		}

	}

}


import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		String [] normal = {"great!","cool","not bad","don't touch me!","don't think so"};
		String [] gumpy = {"are you serious?","Go die in a hole","Terrible","Worse","no way", "Don't even"};

		Scanner sc = new Scanner(System.in);
		for (int i = 0; i < 10; i++) {
			System.out.println(i);
			String res = sc.next();
			for(int j = 0; j < normal.length; j++) {
				if(res.equalsIgnoreCase(normal[j])){
					System.out.println("normal");
					return;
				}
			}
			for(int j = 0; j < gumpy.length; j++) {
				if(res.equalsIgnoreCase(gumpy[j])){
					System.out.println("grumpy");
					return;
				}
			}
			if (i == 9) {
				i = 0;
			}
		}
	}

}


import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		System.out.println(0);
		String res = sc.next();
		if (res.equals("cool")) {
			System.out.println("normal");
		} else {
			System.out.println("grump");
		}

	}

}


import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		System.out.println("normal");

	}

}


import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		System.out.println(1);
		String res = sc.next();
		if (res.equals("cool")) {
			System.out.println("normal");
		} else {
			System.out.println("grumpy");
		}

	}

}


import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		System.out.println(sc);

	}

}


import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		System.out.println(4);
		String res = sc.next();
		if (res.equals("cool")) {
			System.out.println("normal");
		} else {
			System.out.println("grumpy");
		}

	}

}


import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		System.out.println(10);
		String res = sc.next();
		if (res.equals("cool")) {
			System.out.println("normal");
		} else {
			System.out.println("grump");
		}

	}

}


import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		System.out.println(9);
		String res = sc.next();
		if (res.equals("cool")) {
			System.out.println("normal");
		} else {
			System.out.println("grump");
		}

	}

}


import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		System.out.println(6);
		String res = sc.next();
		if (res.equals("cool")) {
			System.out.println("normal");
		} else {
			System.out.println("grumpy");
		}

	}

}


import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		System.out.println(0);
		String res = sc.next();
		System.out.println(res);

	}

}


import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		String [] normal = {"great!","cool","not bad","don't touch me!","don't think so"};
		String [] gumpy = {"are you serious?","Go die in a hole","Terrible","Worse","don't think no way", "Don't even"};

		Scanner sc = new Scanner(System.in);
		for (int i = 0; i < 10; i++) {
			System.out.println(i);
			String res = sc.next();
			for(int j = 0; j < normal.length; j++) {
				if(res.equalsIgnoreCase(normal[j])){
					System.out.println("normal");
					return;
				}
			}
			for(int j = 0; j < gumpy.length; j++) {
				if(res.equalsIgnoreCase(gumpy[j])){
					System.out.println("grumpy");
					return;
				}
			}
			if (i == 9) {
				i = 0;
			}
		}
	}

}


import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		String [] normal = {"great","cool","not bad","don't touch me","don't think so"};
		String [] gumpy = {"are you serious","Go die in a hole","Terrible","Worse","no way", "Don't even"};
		int normals = 0;
		int grumpys = 0;
		Scanner sc = new Scanner(System.in);
		for (int i = 0; i < 10; i++) {
			System.out.println(i);
			String res = sc.next();
			for(int j = 0; j < normal.length; j++) {
				if(res.equalsIgnoreCase(normal[j])){
					normals++;
				}
			}
			for(int j = 0; j < gumpy.length; j++) {
				if(res.equalsIgnoreCase(gumpy[j])){
					grumpys++;
				}
			}
		}
		if(normals > grumpys) {
			System.out.println("normal");
		} else {
			System.out.println("grumpy");

		}
	}

}


import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		String [] normal = {"great!","cool","not bad","don't touch me!","don't think so"};

		Scanner sc = new Scanner(System.in);
		for (int i = 0; i < 10; i++) {
			System.out.println(i);
			String res = sc.next();
			for(int j = 0; j < normal.length; j++) {
				if(res.equalsIgnoreCase(normal[j])){
					System.out.println("normal");
					return;
				}
			}
			if (!res.equalsIgnoreCase("no")) {
				System.out.println("grumpy");
				return;
			}
			if (i == 9) {
				i = 0;
			}
		}
	}

}


import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		String [] normal = {"great!","cool","not bad","don't touch me!","don't think so", "no"};

		Scanner sc = new Scanner(System.in);
		for (int i = 0; i < 10; i++) {
			System.out.println(i);
			String res = sc.next();
			for(int j = 0; j < normal.length; j++) {
				if(res.equalsIgnoreCase(normal[j])){
					System.out.println("normal");
					return;
				}
			}
			if (!res.equalsIgnoreCase("no")) {
				System.out.println("grumpy");
				return;
			}
		}
	}

}


import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		System.out.println(1);
		String res = sc.next();
		if (res.equals("cool")) {
			System.out.println("normal");
		} else if (res.equals("terrible")) {
			System.out.println("grumpy");
		} else {
			while(res.equalsIgnoreCase(res)){}
		}

	}

}


import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		System.out.println(3);
		String res = sc.next();
		if (res.equals("cool")) {
			System.out.println("normal");
		} else {
			System.out.println("grumpy");
		}

	}

}


import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		String [] normal = {"great","cool","not bad","don't touch me","don't think so"};
		String [] gumpy = {"are you serious","Go die in a hole","Terrible","Worse","no way", "Don't even"};

		Scanner sc = new Scanner(System.in);
		for (int i = 0; i < 10; i++) {
			System.out.println(i);
			String res = sc.next();
			for(int j = 0; j < normal.length; j++) {
				if(res.equalsIgnoreCase(normal[j])){
					System.out.println("normal");
					return;
				}
			}
			for(int j = 0; j < gumpy.length; j++) {
				if(res.equalsIgnoreCase(gumpy[j])){
					System.out.println("grumpy");
					return;
				}
			}
			if (i == 9) {
				i = 0;
			}
		}
	}

}


import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.io.UnsupportedEncodingException;
import java.util.StringTokenizer;

public class Main {

    public static void main(String[] args) throws UnsupportedEncodingException, IOException, Exception {
        Reader.init(System.in);
//        StringBuilder out = new StringBuilder();
        for(int i = 0; i < 10; i++) {
            System.out.println(i);
            System.out.flush();
            if(Reader.nextLine().trim().toLowerCase().equals("cool")) {
                System.out.println("normal");
                return;
            }
        }
        System.out.println("grumpy");
//        PrintWriter pw = new PrintWriter(System.out);
//        pw.print(out);
//        pw.close();
    }

}

class Reader {

    static BufferedReader reader;
    static StringTokenizer tokenizer;

    static void init(InputStream input) throws UnsupportedEncodingException {
        reader = new BufferedReader(
                new InputStreamReader(input, "UTF-8"));
        tokenizer = new StringTokenizer("");
    }

    static void init(String url) throws FileNotFoundException {
        reader = new BufferedReader(new FileReader(url));
        tokenizer = new StringTokenizer("");
    }

    static String next() throws IOException {
        while (!tokenizer.hasMoreTokens()) {
            //TODO add check for eof if necessary
            tokenizer = new StringTokenizer(
                    reader.readLine());
        }
        return tokenizer.nextToken();
    }

    static String nextLine() throws IOException {
        return reader.readLine();
    }

    static int nextInt() throws IOException {
        return Integer.parseInt(next());
    }

    static double nextDouble() throws IOException {
        return Double.parseDouble(next());
    }

    static long nextLong() throws IOException {
        return Long.parseLong(next());
    }
}


import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.io.UnsupportedEncodingException;
import java.util.StringTokenizer;

public class Main {

    public static void main(String[] args) throws UnsupportedEncodingException, IOException, Exception {
        Reader.init(System.in);
//        StringBuilder out = new StringBuilder();
        String str;
        for(int i = 0; i < 10; i++) {
            System.out.println(i);
            System.out.flush();
            str = Reader.nextLine().trim().toLowerCase();
            if(str.contains("terrible") || str.contains("worse") || str.contains("go") || str.contains("are") || str.contains("no way") || str.contains("even")) {
                System.out.println("grumpy");
                System.out.flush();
                return;
            } else if(str.contains("great") || str.contains("think") || str.contains("touch") || str.contains("not bad") || str.contains("cool")) {
                System.out.println("normal");
                System.out.flush();
                return;
            }
        }
//        PrintWriter pw = new PrintWriter(System.out);
//        pw.print(out);
//        pw.close();
    }

}

class Reader {

    static BufferedReader reader;
    static StringTokenizer tokenizer;

    static void init(InputStream input) throws UnsupportedEncodingException {
        reader = new BufferedReader(
                new InputStreamReader(input, "UTF-8"));
        tokenizer = new StringTokenizer("");
    }

    static void init(String url) throws FileNotFoundException {
        reader = new BufferedReader(new FileReader(url));
        tokenizer = new StringTokenizer("");
    }

    static String next() throws IOException {
        while (!tokenizer.hasMoreTokens()) {
            //TODO add check for eof if necessary
            tokenizer = new StringTokenizer(
                    reader.readLine());
        }
        return tokenizer.nextToken();
    }

    static String nextLine() throws IOException {
        return reader.readLine();
    }

    static int nextInt() throws IOException {
        return Integer.parseInt(next());
    }

    static double nextDouble() throws IOException {
        return Double.parseDouble(next());
    }

    static long nextLong() throws IOException {
        return Long.parseLong(next());
    }
}


import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.io.UnsupportedEncodingException;
import java.util.StringTokenizer;

public class Main {

    public static void main(String[] args) throws UnsupportedEncodingException, IOException, Exception {
        Reader.init(System.in);
//        StringBuilder out = new StringBuilder();
        String str;
        for(int i = 0; i < 10; i++) {
            System.out.println(i);
            System.out.flush();
            str = Reader.nextLine().trim().toLowerCase();
            if(str.equals("terrible") || str.equals("worse") || str.startsWith("go") || str.startsWith("are") || str.equals("no way") || str.contains("even")) {
                System.out.println("grumpy");
                return;
            }
        }
        System.out.println("normal");
//        PrintWriter pw = new PrintWriter(System.out);
//        pw.print(out);
//        pw.close();
    }

}

class Reader {

    static BufferedReader reader;
    static StringTokenizer tokenizer;

    static void init(InputStream input) throws UnsupportedEncodingException {
        reader = new BufferedReader(
                new InputStreamReader(input, "UTF-8"));
        tokenizer = new StringTokenizer("");
    }

    static void init(String url) throws FileNotFoundException {
        reader = new BufferedReader(new FileReader(url));
        tokenizer = new StringTokenizer("");
    }

    static String next() throws IOException {
        while (!tokenizer.hasMoreTokens()) {
            //TODO add check for eof if necessary
            tokenizer = new StringTokenizer(
                    reader.readLine());
        }
        return tokenizer.nextToken();
    }

    static String nextLine() throws IOException {
        return reader.readLine();
    }

    static int nextInt() throws IOException {
        return Integer.parseInt(next());
    }

    static double nextDouble() throws IOException {
        return Double.parseDouble(next());
    }

    static long nextLong() throws IOException {
        return Long.parseLong(next());
    }
}


import java.util.Scanner;

/**
 * Created by Ayushi on 01/04/2018.
 */
public class p2 {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        String temp;
        for (int i = 0; i < 10; i++) {
            System.out.println(i);
            temp = scan.nextLine();
            if (temp.equals("great") || temp.equals("don't think so") || temp.equals("not bad") || temp.equals("cool") || temp.equals("don't touch me")) {
                System.out.println("normal");
                break;
            }
            else if (temp.equals("don't even") || temp.equals("are you serious?") || temp.equals("worse") || temp.equals("terrible") || temp.equals("go die in a hole") || temp.equals("no way")) {
                System.out.println("grumpy");
                break;
            }
            else {
                continue;
            }
        }
    }
}


import java.io.PrintWriter;
import java.util.Scanner;

public class B {

	public static void main(String[] args)  {
//		FastScanner scan = new FastScanner();
		Scanner scan = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		out.println(8);
		out.flush();
		String in = scan.nextLine();
		if(in.equals("worse")) out.println("grumpy");
		else out.print("normal");
		out.close();
	}

//	static class FastScanner {
//		BufferedReader br;
//		StringTokenizer st;
//
//		public FastScanner() {
//			try	{
//				br = new BufferedReader(new InputStreamReader(System.in));
//				st = new StringTokenizer(br.readLine());
//			} catch (Exception e){e.printStackTrace();}
//		}
//
//		public String next() {
//			if (st.hasMoreTokens())	return st.nextToken();
//			try {st = new StringTokenizer(br.readLine());}
//			catch (Exception e) {e.printStackTrace();}
//			return st.nextToken();
//		}
//
//		public int nextInt() {return Integer.parseInt(next());}
//
//		public long nextLong() {return Long.parseLong(next());}
//
//		public double nextDouble() {return Double.parseDouble(next());}
//
//		public String nextLine() {
//			String line = "";
//			if(st.hasMoreTokens()) line = st.nextToken();
//			else try {return br.readLine();}catch(IOException e){e.printStackTrace();}
//			while(st.hasMoreTokens()) line += " "+st.nextToken();
//			return line;
//		}
//
//		public int[] nextIntArray(int n) {
//			int[] a = new int[n];
//			for(int i = 0; i < n; i++) a[i] = nextInt();
//			return a;
//		}
//
//		public long[] nextLongArray(int n){
//			long[] a = new long[n];
//			for(int i = 0; i < n; i++) a[i] = nextLong();
//			return a;
//		}
//
//		public double[] nextDoubleArray(int n){
//			double[] a = new double[n];
//			for(int i = 0; i < n; i++) a[i] = nextDouble();
//			return a;
//		}
//
//		public char[][] nextGrid(int n, int m){
//			char[][] grid = new char[n][m];
//			for(int i = 0; i < n; i++) grid[i] = next().toCharArray();
//			return grid;
//		}
//	}

}


import java.io.PrintWriter;
import java.util.Scanner;

public class B {

	public static void main(String[] args)  {
//		FastScanner scan = new FastScanner();
		Scanner scan = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		out.println(5);
		out.flush();
		String in = scan.nextLine();
		if(in.equals("worse") || in.equals("are you serious?") || in.equals("go die in a hole") || in.equals("terrible") || in.equals("no way") || in.equals("don't even")) out.println("grumpy");
		else out.print("normal");
		out.close();
	}

//	static class FastScanner {
//		BufferedReader br;
//		StringTokenizer st;
//
//		public FastScanner() {
//			try	{
//				br = new BufferedReader(new InputStreamReader(System.in));
//				st = new StringTokenizer(br.readLine());
//			} catch (Exception e){e.printStackTrace();}s
//		}
//
//		public String next() {
//			if (st.hasMoreTokens())	return st.nextToken();
//			try {st = new StringTokenizer(br.readLine());}
//			catch (Exception e) {e.printStackTrace();}
//			return st.nextToken();
//		}
//
//		public int nextInt() {return Integer.parseInt(next());}
//
//		public long nextLong() {return Long.parseLong(next());}
//
//		public double nextDouble() {return Double.parseDouble(next());}
//
//		public String nextLine() {
//			String line = "";
//			if(st.hasMoreTokens()) line = st.nextToken();
//			else try {return br.readLine();}catch(IOException e){e.printStackTrace();}
//			while(st.hasMoreTokens()) line += " "+st.nextToken();
//			return line;
//		}
//
//		public int[] nextIntArray(int n) {
//			int[] a = new int[n];
//			for(int i = 0; i < n; i++) a[i] = nextInt();
//			return a;
//		}
//
//		public long[] nextLongArray(int n){
//			long[] a = new long[n];
//			for(int i = 0; i < n; i++) a[i] = nextLong();
//			return a;
//		}
//
//		public double[] nextDoubleArray(int n){
//			double[] a = new double[n];
//			for(int i = 0; i < n; i++) a[i] = nextDouble();
//			return a;
//		}
//
//		public char[][] nextGrid(int n, int m){
//			char[][] grid = new char[n][m];
//			for(int i = 0; i < n; i++) grid[i] = next().toCharArray();
//			return grid;
//		}
//	}

}


import java.io.PrintWriter;
import java.util.Scanner;

public class B {

	public static void main(String[] args)  {
//		FastScanner scan = new FastScanner();
		Scanner scan = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		out.println(3);
		out.flush();
		String in = scan.nextLine();
		if(in.equals("worse") || in.equals("are you serious?") || in.equals("go die in a hole") || in.equals("terrible") || in.equals("no way") || in.equals("don't even")) out.println("grumpy");
		else out.print("normal");
		out.close();
	}

//	static class FastScanner {
//		BufferedReader br;
//		StringTokenizer st;
//
//		public FastScanner() {
//			try	{
//				br = new BufferedReader(new InputStreamReader(System.in));
//				st = new StringTokenizer(br.readLine());
//			} catch (Exception e){e.printStackTrace();}s
//		}
//
//		public String next() {
//			if (st.hasMoreTokens())	return st.nextToken();
//			try {st = new StringTokenizer(br.readLine());}
//			catch (Exception e) {e.printStackTrace();}
//			return st.nextToken();
//		}
//
//		public int nextInt() {return Integer.parseInt(next());}
//
//		public long nextLong() {return Long.parseLong(next());}
//
//		public double nextDouble() {return Double.parseDouble(next());}
//
//		public String nextLine() {
//			String line = "";
//			if(st.hasMoreTokens()) line = st.nextToken();
//			else try {return br.readLine();}catch(IOException e){e.printStackTrace();}
//			while(st.hasMoreTokens()) line += " "+st.nextToken();
//			return line;
//		}
//
//		public int[] nextIntArray(int n) {
//			int[] a = new int[n];
//			for(int i = 0; i < n; i++) a[i] = nextInt();
//			return a;
//		}
//
//		public long[] nextLongArray(int n){
//			long[] a = new long[n];
//			for(int i = 0; i < n; i++) a[i] = nextLong();
//			return a;
//		}
//
//		public double[] nextDoubleArray(int n){
//			double[] a = new double[n];
//			for(int i = 0; i < n; i++) a[i] = nextDouble();
//			return a;
//		}
//
//		public char[][] nextGrid(int n, int m){
//			char[][] grid = new char[n][m];
//			for(int i = 0; i < n; i++) grid[i] = next().toCharArray();
//			return grid;
//		}
//	}

}


import java.io.PrintWriter;
import java.util.Scanner;

public class B {

	public static void main(String[] args)  {
//		FastScanner scan = new FastScanner();
		Scanner scan = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		out.println(6);
		out.flush();
		String in = scan.nextLine();
		if(in.equals("worse") || in.equals("are you serious?") || in.equals("go die in a hole") || in.equals("Terrible") || in.equals("no way") || in.equals("no way")) out.println("grumpy");
		else out.print("normal");
		out.close();
	}

//	static class FastScanner {
//		BufferedReader br;
//		StringTokenizer st;
//
//		public FastScanner() {
//			try	{
//				br = new BufferedReader(new InputStreamReader(System.in));
//				st = new StringTokenizer(br.readLine());
//			} catch (Exception e){e.printStackTrace();}
//		}
//
//		public String next() {
//			if (st.hasMoreTokens())	return st.nextToken();
//			try {st = new StringTokenizer(br.readLine());}
//			catch (Exception e) {e.printStackTrace();}
//			return st.nextToken();
//		}
//
//		public int nextInt() {return Integer.parseInt(next());}
//
//		public long nextLong() {return Long.parseLong(next());}
//
//		public double nextDouble() {return Double.parseDouble(next());}
//
//		public String nextLine() {
//			String line = "";
//			if(st.hasMoreTokens()) line = st.nextToken();
//			else try {return br.readLine();}catch(IOException e){e.printStackTrace();}
//			while(st.hasMoreTokens()) line += " "+st.nextToken();
//			return line;
//		}
//
//		public int[] nextIntArray(int n) {
//			int[] a = new int[n];
//			for(int i = 0; i < n; i++) a[i] = nextInt();
//			return a;
//		}
//
//		public long[] nextLongArray(int n){
//			long[] a = new long[n];
//			for(int i = 0; i < n; i++) a[i] = nextLong();
//			return a;
//		}
//
//		public double[] nextDoubleArray(int n){
//			double[] a = new double[n];
//			for(int i = 0; i < n; i++) a[i] = nextDouble();
//			return a;
//		}
//
//		public char[][] nextGrid(int n, int m){
//			char[][] grid = new char[n][m];
//			for(int i = 0; i < n; i++) grid[i] = next().toCharArray();
//			return grid;
//		}
//	}

}


import java.io.PrintWriter;
import java.util.Scanner;

public class B {

	public static void main(String[] args)  {
//		FastScanner scan = new FastScanner();
		Scanner scan = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		out.println(4);
		out.flush();
		String in = scan.nextLine();
		if(in.equals("worse")) out.println("grumpy");
		else out.print("normal");
		out.close();
	}

//	static class FastScanner {
//		BufferedReader br;
//		StringTokenizer st;
//
//		public FastScanner() {
//			try	{
//				br = new BufferedReader(new InputStreamReader(System.in));
//				st = new StringTokenizer(br.readLine());
//			} catch (Exception e){e.printStackTrace();}
//		}
//
//		public String next() {
//			if (st.hasMoreTokens())	return st.nextToken();
//			try {st = new StringTokenizer(br.readLine());}
//			catch (Exception e) {e.printStackTrace();}
//			return st.nextToken();
//		}
//
//		public int nextInt() {return Integer.parseInt(next());}
//
//		public long nextLong() {return Long.parseLong(next());}
//
//		public double nextDouble() {return Double.parseDouble(next());}
//
//		public String nextLine() {
//			String line = "";
//			if(st.hasMoreTokens()) line = st.nextToken();
//			else try {return br.readLine();}catch(IOException e){e.printStackTrace();}
//			while(st.hasMoreTokens()) line += " "+st.nextToken();
//			return line;
//		}
//
//		public int[] nextIntArray(int n) {
//			int[] a = new int[n];
//			for(int i = 0; i < n; i++) a[i] = nextInt();
//			return a;
//		}
//
//		public long[] nextLongArray(int n){
//			long[] a = new long[n];
//			for(int i = 0; i < n; i++) a[i] = nextLong();
//			return a;
//		}
//
//		public double[] nextDoubleArray(int n){
//			double[] a = new double[n];
//			for(int i = 0; i < n; i++) a[i] = nextDouble();
//			return a;
//		}
//
//		public char[][] nextGrid(int n, int m){
//			char[][] grid = new char[n][m];
//			for(int i = 0; i < n; i++) grid[i] = next().toCharArray();
//			return grid;
//		}
//	}

}


import java.io.PrintWriter;
import java.util.Scanner;

public class B {

	public static void main(String[] args)  {
//		FastScanner scan = new FastScanner();
		Scanner scan = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		out.println(6);
		out.flush();
		String in = scan.nextLine();
		if(in.equals("worse")) out.println("grumpy");
		else out.print("normal");
		out.close();
	}

//	static class FastScanner {
//		BufferedReader br;
//		StringTokenizer st;
//
//		public FastScanner() {
//			try	{
//				br = new BufferedReader(new InputStreamReader(System.in));
//				st = new StringTokenizer(br.readLine());
//			} catch (Exception e){e.printStackTrace();}
//		}
//
//		public String next() {
//			if (st.hasMoreTokens())	return st.nextToken();
//			try {st = new StringTokenizer(br.readLine());}
//			catch (Exception e) {e.printStackTrace();}
//			return st.nextToken();
//		}
//
//		public int nextInt() {return Integer.parseInt(next());}
//
//		public long nextLong() {return Long.parseLong(next());}
//
//		public double nextDouble() {return Double.parseDouble(next());}
//
//		public String nextLine() {
//			String line = "";
//			if(st.hasMoreTokens()) line = st.nextToken();
//			else try {return br.readLine();}catch(IOException e){e.printStackTrace();}
//			while(st.hasMoreTokens()) line += " "+st.nextToken();
//			return line;
//		}
//
//		public int[] nextIntArray(int n) {
//			int[] a = new int[n];
//			for(int i = 0; i < n; i++) a[i] = nextInt();
//			return a;
//		}
//
//		public long[] nextLongArray(int n){
//			long[] a = new long[n];
//			for(int i = 0; i < n; i++) a[i] = nextLong();
//			return a;
//		}
//
//		public double[] nextDoubleArray(int n){
//			double[] a = new double[n];
//			for(int i = 0; i < n; i++) a[i] = nextDouble();
//			return a;
//		}
//
//		public char[][] nextGrid(int n, int m){
//			char[][] grid = new char[n][m];
//			for(int i = 0; i < n; i++) grid[i] = next().toCharArray();
//			return grid;
//		}
//	}

}


import java.io.PrintWriter;
import java.util.Scanner;

public class B {

	public static void main(String[] args)  {
//		FastScanner scan = new FastScanner();
		Scanner scan = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		out.println(6);
		out.flush();
		String in = scan.nextLine();
		if(in.equals("worse") || in.equals("are you serious?") || in.equals("go die in a hole") || in.equals("Terrible") || in.equals("no way")) out.println("grumpy");
		else out.print("normal");
		out.close();
	}

//	static class FastScanner {
//		BufferedReader br;
//		StringTokenizer st;
//
//		public FastScanner() {
//			try	{
//				br = new BufferedReader(new InputStreamReader(System.in));
//				st = new StringTokenizer(br.readLine());
//			} catch (Exception e){e.printStackTrace();}
//		}
//
//		public String next() {
//			if (st.hasMoreTokens())	return st.nextToken();
//			try {st = new StringTokenizer(br.readLine());}
//			catch (Exception e) {e.printStackTrace();}
//			return st.nextToken();
//		}
//
//		public int nextInt() {return Integer.parseInt(next());}
//
//		public long nextLong() {return Long.parseLong(next());}
//
//		public double nextDouble() {return Double.parseDouble(next());}
//
//		public String nextLine() {
//			String line = "";
//			if(st.hasMoreTokens()) line = st.nextToken();
//			else try {return br.readLine();}catch(IOException e){e.printStackTrace();}
//			while(st.hasMoreTokens()) line += " "+st.nextToken();
//			return line;
//		}
//
//		public int[] nextIntArray(int n) {
//			int[] a = new int[n];
//			for(int i = 0; i < n; i++) a[i] = nextInt();
//			return a;
//		}
//
//		public long[] nextLongArray(int n){
//			long[] a = new long[n];
//			for(int i = 0; i < n; i++) a[i] = nextLong();
//			return a;
//		}
//
//		public double[] nextDoubleArray(int n){
//			double[] a = new double[n];
//			for(int i = 0; i < n; i++) a[i] = nextDouble();
//			return a;
//		}
//
//		public char[][] nextGrid(int n, int m){
//			char[][] grid = new char[n][m];
//			for(int i = 0; i < n; i++) grid[i] = next().toCharArray();
//			return grid;
//		}
//	}

}