
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Scanner;

class Prvek {
	int x;
	int y;
	
	public Prvek(int x, int y) {
		this.x = x;
		this.y = y;
	}
	
	@Override
	public boolean equals(Object obj) {
		Prvek p  = (Prvek)obj;
		if (x == p.x && y == p.y) {
			return true;
		}
		return false;
	}
}

public class Self {
	
	static int pozice = 4000;

	static ArrayList<Prvek> list = new ArrayList<Prvek>();
	
	
	static int x = pozice;
	static int y = pozice;
	
	static int pocet = -1;
	
	public static boolean nahoru (int n) {
		y--;
		pocet++;
		//System.out.println("start: " + x + " = x : y = " + y);
		for (int i = y; i > y - n; i--) {
			Prvek a = new Prvek(i, x);
			if (list.contains(a) == false) {
				list.add(a);
			} else {
				System.out.println(pocet);
				return true;
			}
		}
		y -= n-1;	
		return false;
	}
	
	public static boolean dolu (int n) {
		y++;
		pocet++;
		//System.out.println("start: " + x + " = x : y = " + y);
		for (int i = y; i < y + n; i++) {
			Prvek a = new Prvek(i, x);
			if (list.contains(a) == false) {
				list.add(a);
			} else {
				System.out.println(pocet);
				return true;
			}
		}
		y += n;
		return false;
	}
	
	public static boolean vpravo (int n) {
		x++;
		pocet++;
		//System.out.println("start: " + x + " = x : y = " + y);
		for (int i = x; i < x + n; i++) {
			Prvek a = new Prvek(y, i);
			if (list.contains(a) == false) {
				list.add(a);
			}  else{
				System.out.println(pocet);
				return true;
			}
		}
		x += n -1;
		return false;
	}
	
	public static boolean vlevo (int n) {
		y--;
		pocet++;
		//System.out.println("start: " + x + " = x : y = " + y);
		for (int i = x-1; i >= x - n; i--) {
			Prvek a = new Prvek(y, i);
			if (list.contains(a) == false) {
				list.add(a);
			}  else {
				System.out.println(pocet);
				return true;
			}
		}
		x -= n;
		return false;

	}
	
	
	public static void main(String[] args) throws IOException {
		
		//Scanner sc = new Scanner(System.in);
		
		
		InputStreamReader a = new InputStreamReader(System.in);
		BufferedReader buf = new BufferedReader(a);
		//buf.
		
		/*String radek;
		while(!(radek = buf.readLine()).equals("")) {
			System.out.println(radek);
		}*/
		
		//buf.
		
		boolean bre = false;
		
		String ra;
		while(buf.read() >= 0) {
			//System.out.println("radek");
			int p = 0;
			
			//int e = sc.nextInt();
			String radek = buf.readLine();
			radek = buf.readLine();
			String cislaS[] = radek.split(" ");
			for (int i = 0; i < cislaS.length; i++) {
				int cislo = Integer.valueOf(cislaS[i]);
				if (p == 0) {
					if (nahoru(cislo)) {
						bre = true;
						//System.out.println("skacu1");10.
						break;
					}
				} else if (p == 1) {
					if(vpravo(cislo)) {
						//System.out.println("skacu2");
						bre = true;
						break;
					}
				} else if (p == 2) {
					if(dolu(cislo)) {
						//System.out.println("skacu3");
						bre = true;
						break;
					}
				} else if (p == 3) {
					if(vlevo(cislo)) {
						//System.out.println("skacu4");
						bre = true;
						break;
					}
					p = -1;
				}
				p++;
			}
			//System.out.println();
			//System.out.println("pocet: " + po);
			if (bre == false) {
				System.out.println("OK");
			}
			list.clear();
			
			x = pozice;
			y = pozice;
			pocet = -1;
			bre = false;
			//vypis();
			//sc.nextLine();
			
			
		}		
		
	}
}




