#include <bits/stdc++.h>
using namespace std;
int tree[300000];
int ar[100005];
int make(int l, int r, int ind) {
  if (l >= r) {
    tree[ind] = ar[r];
    return tree[ind];
  }
  int mid = (l + r) / 2;
  tree[ind] = make(l, mid, 2 * ind + 1) + make(mid + 1, r, 2 * ind + 2);
  return tree[ind];
}
int query(int ql, int qr, int l, int r, int ind) {
  if (ql <= l && qr >= r) {
    return tree[ind];
  }
  if (qr < l || ql > r) return 0;
  int mid = (l + r) / 2;
  return query(ql, qr, l, mid, 2 * ind + 1) +
         query(ql, qr, mid + 1, r, 2 * ind + 2);
}
int main() {
  int n, i, q, l, r;
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> ar[i];
  }
  make(0, n - 1, 0);
  cin >> q;
  while (q--) {
    cin >> l >> r;
    cout << query((l - 1), (r - 1), 0, n - 1, 0) / 10 << endl;
  }
}
