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