#include <bits/stdc++.h>
using namespace std;
long long int power(long long int a, long long int b, long long int m) {
  long long int ans = 1;
  while (b) {
    if (b & 1) ans = (ans * a) % m;
    b /= 2;
    a = (a * a) % m;
  }
  return ans;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long int n, l, r, cnt = 0;
  long long int arr[1000009];
  cin >> n;
  for (long long int i = 1; i < n + 1; i++) {
    cin >> arr[i];
    arr[i] += arr[i - 1];
  }
  long long int q;
  cin >> q;
  while (q--) {
    cin >> l >> r;
    cout << (arr[r] - arr[l - 1]) / 10;
    cout << endl;
  }
}
