#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;
}