#include <iostream>
#include <cmath>
using namespace std;
int main() {
int *x, n, pos, x1 = 0, y1 = 0;
bool f = true;
cin >> n;
int X[] = {-1, 0, 1, 1, 1, 0, -1, -1};
int Y[] = {1, 1, 1, 0, -1, -1, -1, 0};
x = new int [2*n+2];
for (int i = 2; i < (2 * n + 2); i += 2){
cin >> pos;
x1 += X[pos-1];
y1 += Y[pos-1];
x[i] = x1;
x[i+1] = y1;
}
for (int i = 0; i < (2 * n + 2) && f; i += 2)
for (int j = 0; j < i; j += 2)
if ((x[i] == x[j]) && (x[i+1] == x[j+1])){
cout << i / 2;
f = false;
}
if (f) cout << "Ok" << endl << abs(x[2*n+1]) + abs(x[2*n]);
delete []x;
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8Y21hdGg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CgppbnQgbWFpbigpIHsKCWludCAqeCwgbiwgcG9zLCB4MSA9IDAsIHkxID0gMDsKCWJvb2wgZiA9IHRydWU7CgljaW4gPj4gbjsKCWludCBYW10gPSB7LTEsIDAsIDEsIDEsIDEsIDAsIC0xLCAtMX07CglpbnQgWVtdID0gezEsIDEsIDEsIDAsIC0xLCAtMSwgLTEsIDB9OwoJeCA9IG5ldyBpbnQgWzIqbisyXTsKCWZvciAoaW50IGkgPSAyOyBpIDwgKDIgKiBuICsgMik7IGkgKz0gMil7CgkJY2luID4+IHBvczsKCQl4MSArPSBYW3Bvcy0xXTsKCQl5MSArPSBZW3Bvcy0xXTsKCQl4W2ldID0geDE7CgkJeFtpKzFdID0geTE7Cgl9Cglmb3IgKGludCBpID0gMDsgaSA8ICgyICogbiArIDIpICYmIGY7IGkgKz0gMikKCQlmb3IgKGludCBqID0gMDsgaiA8IGk7IGogKz0gMikKCQkJaWYgKCh4W2ldID09IHhbal0pICYmICh4W2krMV0gPT0geFtqKzFdKSl7CgkJCQljb3V0IDw8IGkgLyAyOyAKCQkJCWYgPSBmYWxzZTsKCQkJfQoJaWYgKGYpIGNvdXQgPDwgIk9rIiA8PCBlbmRsIDw8IGFicyh4WzIqbisxXSkgKyBhYnMoeFsyKm5dKTsKCWRlbGV0ZSBbXXg7CglyZXR1cm4gMDsKfQ==