#include <iostream>
#include <cmath>
using namespace std;
int main() {
int *x, *y, n, pos, x1 = 0, y1 = 0;
bool f = true;
cin >> n;
x = new int [n];
y = new int [n];
for (int i = 1; i <= n; i ++){
cin >> pos;
if (pos == 1){
x1 -= 1;
y1 += 1;
}
else if (pos == 2) y1 += 1;
else if (pos == 3){
x1 += 1;
y1 += 1;
}
else if (pos == 4) x1 += 1;
else if (pos == 5){
x1 += 1;
y1 -= 1;
}
else if (pos == 6) y1 -= 1;
else if (pos == 7){
x1 -= 1;
y1 -= 1;
}
else if (pos == 8) x1 -= 1;
x[i] = x1;
y[i] = y1;
}
for (int i = 1; i < n && f; i++)
for (int j = 0; j < i; j++)
if ((x[i] == x[j]) && (y[i] == y[j])){
cout << i;
f = false;
}
if (f) cout << "Ok" << endl << abs(x[n]) + abs(y[n]);
delete []x;
delete []y;
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8Y21hdGg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CgppbnQgbWFpbigpIHsKCWludCAqeCwgKnksIG4sIHBvcywgeDEgPSAwLCB5MSA9IDA7Cglib29sIGYgPSB0cnVlOwoJY2luID4+IG47Cgl4ID0gbmV3IGludCBbbl07Cgl5ID0gbmV3IGludCBbbl07Cglmb3IgKGludCBpID0gMTsgaSA8PSBuOyBpICsrKXsKCQljaW4gPj4gcG9zOwoJCWlmIChwb3MgPT0gMSl7CgkJCXgxIC09IDE7CgkJCXkxICs9IDE7CgkJfQoJCWVsc2UgaWYgKHBvcyA9PSAyKSB5MSArPSAxOwoJCWVsc2UgaWYgKHBvcyA9PSAzKXsKCQkJeDEgKz0gMTsKCQkJeTEgKz0gMTsKCQl9CgkJZWxzZSBpZiAocG9zID09IDQpIHgxICs9IDE7CgkJZWxzZSBpZiAocG9zID09IDUpewoJCQl4MSArPSAxOwoJCQl5MSAtPSAxOwoJCX0KCQllbHNlIGlmIChwb3MgPT0gNikgeTEgLT0gMTsKCQllbHNlIGlmIChw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