#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  long long int sum[n + 10];
  sum[0] = 0;
  for (int i = 1; i <= n; i++) {
    long long int a;
    cin >> a;
    sum[i] = sum[i - 1] + a;
  }
  int q;
  cin >> q;
  for (int i = 1; i <= q; i++) {
    int l, r;
    cin >> l >> r;
    long long int val = sum[r] - sum[l - 1];
    cout << val / 10 << endl;
  }
  return 0;
}
