#include <bits/stdc++.h>
using namespace std;
int arr[100010] = {0}, cumsum[100010] = {0};
int solve(int l, int r) { return (cumsum[r] - cumsum[l - 1]) / 10; }
int main() {
  int n, q, l, r;
  scanf("%d", &n);
  for (int a = 1; a <= n; a++) {
    scanf("%d", &arr[a]);
    cumsum[a] = cumsum[a - 1] + arr[a];
  }
  scanf("%d", &q);
  while (q--) {
    scanf("%d %d", &l, &r);
    printf("%d\n", solve(l, r));
  }
  return 0;
}
