#include <bits/stdc++.h>
using namespace std;
const int maxn = 100005;
int n, m;
vector<int> arr;
vector<int> tree[4 * maxn][2];
void build(int rt, vector<int> &a) {
  if (a.size() <= 1) {
    return;
  }
  tree[rt][0].push_back(0);
  tree[rt][1].push_back(0);
  vector<int> tmp;
  tmp.clear();
  for (int i = 0; i + 1 < a.size(); i += 2) {
    int x = a[i] + a[i + 1];
    tree[rt][0].push_back(tree[rt][0].back() + (x >= 10));
    tmp.push_back(x % 10);
  }
  tree[rt][0].shrink_to_fit();
  build(rt << 1, tmp);
  tmp.clear();
  for (int i = 1; i + 1 < a.size(); i += 2) {
    int x = a[i] + a[i + 1];
    tree[rt][1].push_back(tree[rt][1].back() + (x >= 10));
    tmp.push_back(x % 10);
  }
  tree[rt][1].shrink_to_fit();
  build(rt << 1 | 1, tmp);
}
int query(int rt, int l, int r) {
  if (l == r) return 0;
  int sel = (l & 1) ^ 1;
  l -= sel, r -= sel;
  int L = (l + 1) >> 1, R = (r + 1) >> 1;
  int ans = tree[rt][sel][R] - tree[rt][sel][L - 1];
  ans += query(rt << 1 | sel, L, R);
  return ans;
}
void work() {
  scanf(" %d", &m);
  while (m--) {
    int l, r;
    scanf(" %d%d", &l, &r);
    int ans = query(1, l, r);
    printf("%d\n", ans);
  }
}
int main() {
  scanf(" %d", &n);
  for (int i = 0; i < n; ++i) {
    int x;
    scanf(" %d", &x);
    arr.push_back(x);
  }
  build(1, arr);
  work();
  return 0;
}
