#include <iostream>
#include "data.h" // arr, N, LOG_N, INF

using namespace std;

int sp[N][LOG_N]; 

int rmq(int l, int r) {
	int k = 1;
	int pow_k = 1;

	while (pow_k*2 < r-l) {
		k++;
		pow_k *= 2;
	}
	
	return min(sp[l][k], sp[r-pow_k-1][k]);
}

int main() {
	printArr();

	//setup sparse table
	for (int i = 0; i < N; i++)
		sp[i][0] = arr[i];
	for (int k = 0; k < LOG_N; k++)
	    for (int i = 0; i + (1<<k) < N; i++)
		sp[i][k+1] = min(sp[i][k], sp[i+(1<<k)][k]);
	
	int rmq_min = rmq(3, 7);
	int naive_min = INF;
	
	for (int i = 3; i <= 7; i++)
		naive_min = min(naive_min, arr[i]);
	
	cout << "min(a[3], ..., a[7]) = " << rmq_min << endl;
	cout << (rmq_min == naive_min ? "Correct!" : "Incorrect!") << endl;
		
	return 0;
}
