#include <bits/stdc++.h>
using namespace std;
template <class T>
bool uin(T &a, T b) {
  return a > b ? (a = b, true) : false;
}
template <class T>
bool uax(T &a, T b) {
  return a < b ? (a = b, true) : false;
}
long long a[100001];
int main() {
  long long n;
  cin >> n;
  for (long long i = 1; i <= (long long)(n); ++i) {
    cin >> a[i];
    a[i] += a[i - 1];
  }
  long long q;
  cin >> q;
  while (q--) {
    long long b, c;
    cin >> b >> c;
    long long ans = (a[c] - a[b - 1]) / 10;
    cout << ans << "\n";
  }
}
