import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int[] asc = new int[n]; int[] dsc = new int[n]; asc[0] = 1; dsc[0] = 1; int prev = sc.nextInt(); for (int i = 1; i < n; i++) { int x = sc.nextInt(); if (prev <= x) { asc[i] = asc[i - 1] + 1; } else { asc[i] = 1; } if (prev >= x) { dsc[i] = dsc[i - 1] + 1; } else { dsc[i] = 1; } prev = x; } int q = sc.nextInt(); StringBuilder sb = new StringBuilder(); for (int i = 0; i < q; i++) { int left = sc.nextInt(); int right = sc.nextInt(); if (asc[right] - asc[left] == right - left) { sb.append(1); } else { sb.append(0); } sb.append(" "); if (dsc[right] - dsc[left] == right - left) { sb.append(1); } else { sb.append(0); } sb.append("\n"); } System.out.print(sb); } }