#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int tab[n];
  cin >> tab[0];
  for (int i = 1; i < n; i++) {
    int c;
    cin >> c;
    tab[i] = tab[i - 1] + c;
  }
  int num;
  cin >> num;
  for (int i = 0; i < num; i++) {
    int beg, en;
    cin >> beg >> en;
    int c;
    if (beg > 1) {
      c = tab[en - 1] - tab[beg - 2];
    } else {
      c = tab[en - 1];
    }
    cout << c / 10 << endl;
  }
  return 0;
}
