#include <bits/stdc++.h>
using namespace std;
int n, t[111111];
void upd(int x, int val) {
  for (int i = x; i <= n; i = (i | (i + 1))) {
    t[i] += val;
  }
}
int get(int x) {
  int res = 0;
  for (int i = x; i > 0; i = (i & (i + 1)) - 1) {
    res += t[i];
  }
  return res;
}
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    int x;
    cin >> x;
    upd(i, x);
  }
  int m;
  cin >> m;
  for (int i = 1; i <= m; i++) {
    int l, r;
    cin >> l >> r;
    int sum = (get(r) - get(l - 1));
    cout << sum / 10 << endl;
  }
  return 0;
}
