#include <bits/stdc++.h>
using namespace std;
bool com(int a, int b) { return a > b; }
int a[1000005], b[1000005];
int main() {
  int n, t;
  cin >> n;
  a[0] = 0, b[0] = 0;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    b[i] = a[i] + b[i - 1];
  }
  cin >> t;
  while (t--) {
    int l, r, j = 1, ans = 0;
    cin >> l >> r;
    ans = (b[r] - b[l - 1]) / 10;
    cout << ans << endl;
  }
  return 0;
}
