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