#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
int main() {
  int n;
  cin >> n;
  vector<int> a(n + 1);
  a[0] = 0;
  for (int i = 1; i < n + 1; i++) {
    cin >> a[i];
  }
  for (int i = 2; i < n + 1; i++) {
    a[i] += a[i - 1];
  }
  int q;
  cin >> q;
  while (q--) {
    int l, r;
    cin >> l >> r;
    cout << ((a[r] - a[l - 1]) / 10) << '\n';
  }
  return 0;
}
