#include #include #include #include using namespace std; struct Coord { Coord(int x = 0, int y = 0) : x(x), y(y) {} bool operator<(const Coord & r) const { if(x != r.x) return x < r.x; else return y < r.y; } bool operator==(const Coord & r) const { return (x == r.x) && (y == r.y); } int x; int y; }; void move(vector & coords, int & a, int & b, int dir, int steps) { for(int i = 0; i < steps; i++) { switch(dir) { case 0: b += 1; break; case 1: a += 1; break; case 2: b -= 1; break; default: a -= 1; break; } Coord c(a, b); coords.push_back(c); } } int main(void) { do { vector coords; //coords.insert(Coord(0, 0)); string str; getline(cin, str); if(str.length() == 0) break; int n, dir = 0, a = 0, b = 0, count = 0; sscanf(str.c_str(), "%d", &n); for(int i = 0; i < n; i++) { int steps; scanf(" %d ", &steps); move(coords, a, b, dir, steps); dir = (dir + 1) % 4; } sort(coords.begin(), coords.end()); for(unsigned int i = 0; i < coords.size()-1; i++) if(coords[i] == coords[i+1]) count++; if(count) cout << n-count << endl; else cout << "OK" << endl; } while(cin.good()); return 0; }