#include <bits/stdc++.h>
using namespace std;
const int PRIME = 1e9 + 7;
const int INF = 2e9;
const int MAX_N = 1e5 + 6;
long long ans = 0;
int n, m, q, l, r;
int a[MAX_N][20];
int sum[MAX_N][20];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = (int)(0); i < (int)(n); ++i) {
    cin >> a[i][0];
    sum[i][0] = 0;
  }
  for (int k = 1; (1 << k) <= n; ++k) {
    for (int i = (int)(0); i <= (int)(n - (1 << k)); ++i) {
      a[i][k] = a[i][k - 1] + a[i + (1 << (k - 1))][k - 1];
      sum[i][k] = sum[i][k - 1] + sum[i + (1 << (k - 1))][k - 1];
      if (a[i][k] >= 10) {
        a[i][k] -= 10;
        sum[i][k]++;
      }
    }
  }
  cin >> q;
  while (q--) {
    cin >> l >> r;
    m = r - l + 1;
    int k = -1;
    while (m > 0) {
      m >>= 1;
      ++k;
    }
    cout << sum[l - 1][k] << "\n";
  }
  return 0;
}
