#include <bits/stdc++.h>
using namespace std;
const int SIZE = 1e5 + 10;
int a[SIZE], n, q, x, y;
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &x);
    a[i] = a[i - 1] + x;
  }
  scanf("%d", &q);
  while (q--) {
    scanf("%d%d", &x, &y);
    printf("%d\n", (a[y] - a[x - 1]) / 10);
  }
  return 0;
}
