#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f;
const int maxn = 1e5 + 5;
const int mod = 1e9 + 7;
int n, a[maxn], sum[maxn];
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i], sum[i] = sum[i - 1] + a[i];
  int q, l, r;
  cin >> q;
  while (q--) {
    cin >> l >> r;
    cout << (sum[r] - sum[l - 1]) / 10 << endl;
  }
  return 0;
}
