#include <bits/stdc++.h>
using namespace std;
const int MAXN = 212345;
int n, q, s[MAXN], L, R;
int query() { return (s[R] - s[L - 1]) / 10; }
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) {
    scanf("%d", &s[i]);
    s[i] += s[i - 1];
  }
  scanf("%d", &q);
  while (q--) {
    scanf("%d %d", &L, &R);
    printf("%d\n", query());
  }
  return 0;
}
