#include #include #include #include #include #include int main() { std::ios_base::sync_with_stdio(false); int N; std::vector L; L.reserve(1000000); while (std::cin >> N) { // input L.clear(); L.push_back(0); L.push_back(0); for (int i = 0; i < N; ++i) { L.push_back(i); std::cin >> L.back(); } if (N < 4) { std::cout << "OK\n"; continue; } std::vector::iterator l = L.begin() + 4; // unwind for (; l != L.end(); ++l) { if (*l <= *(l - 2)) { int gap = *(l - 2) - *(l - 4); if (*l >= gap) { *(l - 1) = *(l - 1) - *(l - 3); } //std::cout << "unwind done at " << (l - L.begin() - 1) << "\n"; break; } } ++l; // wind bool fail = false; for (; l < L.end(); ++l) { if (*l >= *(l - 2)) { fail = true; break; } } // output if (fail) { std::cout << (l - L.begin() - 2) << '\n'; } else { std::cout << "OK\n"; } } return 0; }