#include <bits/stdc++.h>
using namespace std;
int const maxn = 1e5 + 5;
long long a[maxn];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%lld", &a[i]);
  for (int i = 2; i <= n; i++) a[i] = a[i] + a[i - 1];
  int q;
  scanf("%d", &q);
  int l, r;
  while (q--) {
    scanf("%d%d", &l, &r);
    printf("%lld\n", (a[r] - a[l - 1]) / 10);
  }
}
