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