#include <bits/stdc++.h>
using namespace std;
int a[100001], b[100001];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, x, l, r, q;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    b[i] = a[i] + b[i - 1];
  }
  cin >> q;
  while (q--) {
    cin >> l >> r;
    cout << (b[r] - b[l - 1]) / 10 << "\n";
  }
  return 0;
}
