#include <bits/stdc++.h>
using namespace std;
const int maxn = 4e5 + 5;
long long a[maxn];
long long b[maxn];
char s[400];
int main() {
  std::ios::sync_with_stdio(false);
  int n;
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    cin >> a[i];
    b[i] = b[i - 1] + a[i];
  }
  int t;
  cin >> t;
  while (t--) {
    int p, q;
    cin >> p >> q;
    cout << (b[q] - b[p - 1]) / 10LL << endl;
  }
  return 0;
}
