#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, aux, suma = 0;
  cin >> n;
  vector<int> digits = vector<int>(n + 1);
  digits[0] = 0;
  for (int i(1); i <= n; i++) {
    cin >> aux;
    suma += aux;
    digits[i] = suma;
  }
  int queries, leftSide, rightSide;
  cin >> queries;
  for (int q(0); q < queries; q++) {
    cin >> leftSide;
    cin >> rightSide;
    cout << (digits[rightSide] - digits[leftSide - 1]) / 10 << endl;
  }
  return 0;
}
