#include <bits/stdc++.h>
using namespace std;
void inOut();
int arr[101010], arr2[101010];
int main() {
  inOut();
  int i, j, q, m, n;
  cin >> n;
  for (i = 0; i < n; i++) cin >> arr[i];
  for (i = 0; i < n; i++) arr2[i + 1] = arr2[i] + arr[i];
  cin >> m;
  while (m--) {
    int l, r;
    cin >> l >> r;
    l--;
    cout << (arr2[r] - arr2[l]) / 10 << endl;
  }
  return 0;
}
void inOut() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
}
