#define TASKNAME "bumblebee"
#include <cstdio>
#include <algorithm>
#include <vector>
 
using namespace std;
 
typedef vector <int> vi;

int main()
{
  freopen(TASKNAME".in", "r", stdin);
  freopen(TASKNAME".out", "w", stdout);
  int n;
  scanf("%d", &n);
  vi a(n), pref(n + 1, 0);
  pref[0] = 0;
  for (int i = 0; i < n; i++)
    scanf("%d", &a[i]), pref[i + 1] = pref[i] + (a[i] == 1);
  int q;
  scanf("%d", &q);
  for (int i = 0; i < q; i++)
  {
    int l, r;
    scanf("%d%d", &l, &r);
    int ones_count = pref[r] - pref[l - 1];
    printf("%d\n", ones_count == r - l + 1 ? 2 : 1);
  }
  return 0;
}

