#include <bits/stdc++.h>
using namespace std;
int ar[100001], csum[100001];
int main() {
  ios::sync_with_stdio(0), cin.tie(NULL), cout.tie(NULL);
  int n, q;
  cin >> n;
  for (int i = 0; i < n; i++) cin >> ar[i];
  for (int i = 1; i <= n; i++) {
    csum[i] = csum[i - 1] + ar[i - 1];
  }
  cin >> q;
  while (q--) {
    int l, r;
    cin >> l >> r;
    cout << (csum[r] - csum[l - 1]) / 10 << "\n";
  }
  return 0;
}
