#include <bits/stdc++.h>
int n;
int s[100001], a, q, l, r;
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &a), s[i] = s[i - 1] + a;
  scanf("%d", &q);
  while (q--) {
    scanf("%d%d", &l, &r);
    printf("%d\n", (s[r] - s[l - 1]) / 10);
  }
}
