#include <bits/stdc++.h>
using namespace std;
int ar[100001];
int main() {
  int i, n, j, q;
  unordered_map<int, vector<pair<int, int>>> dp;
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> ar[i];
  }
  int k = 1;
  while (k <= n) {
    for (int i = 0; i + k <= n; i++) {
      if (k == 1) {
        dp[1].push_back({ar[i], 0});
      } else {
        int half = k / 2;
        pair<int, int> v1 = dp[half][i];
        pair<int, int> v2 = dp[half][i + half];
        int ans = v1.second + v2.second;
        int val = (v1.first + v2.first) % 10;
        if (v1.first + v2.first >= 10) ans++;
        dp[k].push_back({val, ans});
      }
    }
    k *= 2;
  }
  cin >> q;
  while (q--) {
    int l, r;
    cin >> l >> r;
    int k = r - l + 1;
    int ans = dp[k][l - 1].second;
    cout << ans << endl;
  }
  return 0;
}
