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