import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
public class Main {
public static void main(String[] args) throws IOException {
BjSolution sol = new BjSolution();
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
br.readLine();
String nums = br.readLine();
int quizCount = Integer.parseInt(br.readLine());
String[] quizs = new String[quizCount];
for (int i = 0; i < quizCount; i++) {
quizs[i] = br.readLine();
}
sol.solution(nums, quizs);
}
}
class BjSolution {
private int[] arr;
public void solution(String nums, String[] quizs) {
arr = Arrays.stream(nums.split(" ")).mapToInt(Integer::parseInt).toArray();
StringBuilder sb = new StringBuilder();
for (String quiz : quizs) {
sb.append(isPalindrome(quiz)).append("\n");
}
System.out.println(sb);
}
private int isPalindrome(String quiz) {
String[] quizConditions = quiz.split(" ");
int start = Integer.parseInt(quizConditions[0]) - 1;
int end = Integer.parseInt(quizConditions[1]) - 1;
int count = end - start + 1;
int limit;
if (count % 2 == 1) {
limit = count / 2;
}
else {
limit = count / 2 + 1;
}
for (int i = 0; i < limit; i++) {
if (arr[start + i] != arr[end - i]) {
return 0;
}
}
return 1;
}
}