#include <bits/stdc++.h>
using namespace std;
int main() {
  int num;
  cin >> num;
  vector<int> vec;
  for (int ix = 0; ix < num; ix++) {
    int seq;
    cin >> seq;
    vec.push_back(seq);
  }
  vector<int> ivec(vec.size() + 1);
  ivec[0] = 0;
  for (int ix = 1; ix < vec.size() + 1; ix++) {
    ivec[ix] = ivec[ix - 1] + vec[ix - 1];
  }
  int qu;
  cin >> qu;
  for (int tx = 0; tx < qu; tx++) {
    int le, ri;
    cin >> le >> ri;
    cout << (ivec[ri] - ivec[le - 1]) / 10 << endl;
  }
  return 0;
}
