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