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