import java.io.*; import java.util.*; public class Main { public static void main(String[] args) throws Exception { Scanner sc = new Scanner(); int n = sc.nextInt(); long prev = sc.nextLong(); int[] acc = new int[n]; int[] dec = new int[n]; for (int i = 1; i < n; i++) { long x = sc.nextLong(); if (prev <= x) { acc[i] = acc[i - 1] + 1; } else { acc[i] = 0; } if (prev >= x) { dec[i] = dec[i - 1] + 1; } else { dec[i] = 0; } prev = x; } int q = sc.nextInt(); StringBuilder sb = new StringBuilder(); while (q-- > 0) { int left = sc.nextInt(); int right = sc.nextInt(); if (acc[right] - acc[left] == right - left) { sb.append("1 "); } else { sb.append("0 "); } if (dec[right] - dec[left] == right - left) { sb.append("1\n"); } else { sb.append("0\n"); } } System.out.print(sb); } } class Scanner { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(""); StringBuilder sb = new StringBuilder(); public Scanner() throws Exception { } public int nextInt() throws Exception { return Integer.parseInt(next()); } public long nextLong() throws Exception { return Long.parseLong(next()); } public double nextDouble() throws Exception { return Double.parseDouble(next()); } public String next() throws Exception { while (!st.hasMoreTokens()) { st = new StringTokenizer(br.readLine()); } return st.nextToken(); } }