#include <bits/stdc++.h>
using namespace std;
#pragma warning(disable : 4996)
const int maxn = 100005;
int sum[maxn];
int main() {
  int n, x;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &x);
    sum[i] += sum[i - 1] + x;
  }
  int q, l, r;
  scanf("%d", &q);
  while (q--) {
    scanf("%d%d", &l, &r);
    printf("%d\n", (sum[r] - sum[l - 1]) / 10);
  }
}
