#include <bits/stdc++.h>
using namespace std;
int arr[100001];
int n;
void candies(int q, int n) {
  long long dp[100001];
  dp[0] = arr[0];
  for (int i = 1; i < n; i++) {
    dp[i] = dp[i - 1] + arr[i];
  }
  while (q--) {
    int l, r;
    cin >> l >> r;
    long long total = dp[r - 1];
    if (l - 2 >= 0) total -= dp[l - 2];
    cout << total / 10 << endl;
  }
  return;
}
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) cin >> arr[i];
  int q;
  cin >> q;
  candies(q, n);
  return 0;
}
