import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.StringTokenizer;

public class Self {

    static StringTokenizer st = new StringTokenizer("");
    static BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
    //static BufferedReader input;
    
    static Map<Integer, Map<Integer, Boolean>> grid;

    static String nextToken() throws Exception {
        while (!st.hasMoreTokens()) {
            st = new StringTokenizer(input.readLine());
        }
        return st.nextToken();
    }

    static int nextInt() throws Exception {
        return Integer.parseInt(nextToken());
    }
    
    public static int mapnum(int a) {
        if (a <= 0)
            return a * -2;
        else return a * 2 - 1;
    }
    
    public static boolean storeMap(int posx, int posy) {
        posx = mapnum(posx);
        posy = mapnum(posy);
        
        Map<Integer, Boolean> gridx = grid.get(posx);
        if (gridx == null) {
            gridx = new HashMap<Integer, Boolean>();
            gridx.put(posy, true);
            grid.put(posx, gridx);
            return true;
        }
        
        Boolean gridxy = gridx.get(posy);
        if (gridxy == null) {
            gridx.put(posy, true);
            return true;
        }
        
        if (gridxy == true) {
            return false;
        }
        
        return true;
    }
    
    public static void main(String[] args) throws IOException, Exception {
        String line;

        //input = new BufferedReader(new InputStreamReader(new FileInputStream("test.in")));
        while ((line = input.readLine()) != null) {
            st = new StringTokenizer(line);

            int N = nextInt();
            int dir = 0;
            int posx = 0;
            int posy = 0;
            
            int cnt = 0;
            boolean isok = true;
            
            grid = new HashMap<Integer, Map<Integer, Boolean>>();
            for (int i = 0; i < N; i++) {
              int step = nextInt();
              boolean cycled = false;
              
              // nahoru
              if (!cycled && dir == 0) {
                  for (int j = posy + 1; j <= posy + step; j++) {
                      isok = storeMap(posx, j);
                      if (!isok) break;
                  }
                  posy += step;
                  dir = 1;
                  cycled = true;
              }
              // doprava
              if (!cycled && dir == 1) {
                  for (int j = posx + 1; j <= posx + step; j++) {
                      isok = storeMap(j, posy);
                      if (!isok) break;
                  }
                  posx += step;
                  dir = 2;
                  cycled = true;
              }
              // dolu
              if (!cycled && dir == 2) {
                  for (int j = posy - 1; j >= posy - step; j--) {
                      isok = storeMap(posx, j);
                      if (!isok) break;
                  }
                  posy -= step;
                  dir = 3;
                  cycled = true;
              }
              // doprava
              if (!cycled && dir == 3) {
                  for (int j = posx - 1; j >= posx - step; j--) {
                      isok = storeMap(j, posy);
                      if (!isok) break;
                  }
                  posx -= step;
                  dir = 0;
                cycled = true;
              }
              
              if (!isok) {
                  System.out.println(cnt);
                  break;
              }

              cnt++;
              
            }
            
            if (isok) {
                System.out.println("OK");
            }
                
            //System.out.println("Minimalni budova obsahuje "+L+" kostek, maximalni "+M+" kostek.");
                
        }

    }

}
