import java.util.*;
import java.lang.*;
import java.io.*;
class Main
{
{
Scanner in
= new Scanner
(System.
in); int[][] x = new int[2001][2001];
int n = in.nextInt();
int move;
int xPos=1001, yPos=1001;
for(int i = 0; i < n; i++) {
move = in.nextInt();
if(x[xPos][yPos] == 1) {
return;
}
else x[xPos][yPos]=1;
if(move == 1) {
xPos--;
yPos++;
}
if(move == 2) {
yPos++;
}
if(move == 3) {
xPos++;
yPos++;
}
if(move == 4) {
xPos++;
}
if(move == 5) {
xPos++;
yPos--;
}
if(move == 6) {
yPos--;
}
if(move == 7) {
xPos--;
yPos--;
}
if(move == 8) {
xPos--;
}
}
System.
out.
print("Ok" + "\n" + (Math.
abs(xPos
-1001)+Math.
abs(yPos
-1001))); }
}
aW1wb3J0IGphdmEudXRpbC4qOwppbXBvcnQgamF2YS5sYW5nLio7CmltcG9ydCBqYXZhLmlvLio7CgpjbGFzcyBNYWluCnsKCXB1YmxpYyBzdGF0aWMgdm9pZCBtYWluIChTdHJpbmdbXSBhcmdzKSB0aHJvd3MgamF2YS5sYW5nLkV4Y2VwdGlvbgoJewoJCVNjYW5uZXIgaW4gPSBuZXcgU2Nhbm5lcihTeXN0ZW0uaW4pOwoJCWludFtdW10geCA9IG5ldyBpbnRbMjAwMV1bMjAwMV07CgkJaW50IG4gPSBpbi5uZXh0SW50KCk7CgkJaW50IG1vdmU7CgkJaW50IHhQb3M9MTAwMSwgeVBvcz0xMDAxOwoJCWZvcihpbnQgaSA9IDA7IGkgPCBuOyBpKyspIHsKCQkJbW92ZSA9IGluLm5leHRJbnQoKTsKCQkJaWYoeFt4UG9zXVt5UG9zXSA9PSAxKSB7IAogICAgICAgICAgICAJU3lzdGVtLm91dC5wcmludChpKTsKICAgICAgICAgICAgCXJldHVybjsKICAgICAgICAJfQogICAgICAgIAllbHNlIHhbeFBvc11beVBvc109MTsKCSAgICAgICAgaWYobW92ZSA9PSAxKSB7CgkgICAgICAgICAgICB4UG9zLS07CgkgICAgICAgICAgICB5UG9zKys7CgkgICAgICAgIH0KCSAgICAgICAgaWYobW92ZSA9PSAyKSB7CgkgICAgICAgICAgICB5UG9zKys7CgkgICAgICAgIH0KCSAgICAgICAgaWYobW92ZSA9PSAzKSB7CgkgICAgICAgICAgICB4UG9zKys7CgkgICAgICAgICAgICB5UG9zKys7CgkgICAgICAgIH0KCSAgICAgICAgaWYobW92ZSA9PSA0KSB7CgkgICAgICAgICAgICB4UG9zKys7CgkgICAgICAgIH0KCSAgICAgICAgaWYobW92ZSA9PSA1KSB7CgkgICAgICAgICAgICB4UG9zKys7CgkgICAgICAgICAgICB5UG9zLS07CgkgICAgICAgIH0KCSAgICAgICAgaWYobW92ZSA9PSA2KSB7CgkgICAgICAgICAgICB5UG9zLS07CgkgICAgICAgIH0KCSAgICAgICAgaWYobW92ZSA9PSA3KSB7CgkgICAgICAgICAgICB4UG9zLS07CgkgICAgICAgICAgICB5UG9zLS07CgkgICAgICAgIH0KCSAgICAgICAgaWYobW92ZSA9PSA4KSB7CgkgICAgICAgICAgICB4UG9zLS07CgkgICAgICAgIH0KCQl9CgkJU3lzdGVtLm91dC5wcmludCgiT2siICsgIlxuIiArIChNYXRoLmFicyh4UG9zLTEwMDEpK01hdGguYWJzKHlQb3MtMTAwMSkpKTsKCX0KfQ==