#include <bits/stdc++.h>
using namespace std;
const long long maxn = 1e5 + 5;
long long s[maxn];
long long p[maxn];
signed main() {
  long long n;
  cin >> n;
  for (long long i = 1; i <= n; i++) cin >> s[i];
  for (long long i = 1; i <= n; i++) p[i] = p[i - 1] + s[i];
  long long t;
  cin >> t;
  while (t--) {
    long long l, r;
    cin >> l >> r;
    cout << (p[r] - p[l - 1]) / 10 << endl;
  }
  return 0;
}
