#include <bits/stdc++.h>
using namespace std;
int main(int argc, char const *argv[]) {
  int n, q, counts = 0;
  cin >> n;
  int s[n];
  for (int i = 0; i < n; i++) cin >> s[i];
  cin >> q;
  int l[q], r[q];
  for (int i = 0; i < q; i++) cin >> l[i] >> r[i];
  int sums[n + 1];
  sums[0] = 0;
  for (int i = 1; i < n + 1; i++) sums[i] = sums[i - 1] + s[i - 1];
  for (int i = 0; i < q; i++)
    cout << (sums[r[i]] - sums[l[i] - 1]) / 10 << endl;
  return 0;
}
