#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int a[n];
  int prefix[n + 1];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  prefix[0] = 0;
  for (int i = 1; i <= n; i++) {
    prefix[i] = prefix[i - 1] + a[i - 1];
  }
  int q;
  cin >> q;
  while (q--) {
    int l, r;
    cin >> l >> r;
    cout << (prefix[r] - prefix[l - 1]) / 10 << endl;
  }
  return 0;
}
