#include <bits/stdc++.h>
using namespace std;
long long v1[25][200005], v2[25][200005];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long n;
  cin >> n;
  vector<long long> a(n);
  for (long long i = 0; i < (long long)n; ++i) {
    cin >> a[i];
  }
  long long sz = log2(n);
  for (long long i = 0; i < (long long)sz + 1; ++i) {
    for (long long j = 0; j < (long long)n; ++j) {
      if (i == 0) {
        v1[i][j] = a[j];
        v2[i][j] = 0;
      } else {
        v1[i][j] = v1[i - 1][j] + v1[i - 1][j + (1 << (i - 1))];
        v2[i][j] = v2[i - 1][j] + v2[i - 1][j + (1 << (i - 1))];
        if (v1[i][j] >= 10) v2[i][j]++;
        v1[i][j] %= 10;
      }
    }
  }
  long long q;
  cin >> q;
  while (q--) {
    long long x, y;
    cin >> x >> y;
    --x;
    --y;
    long long lg = log2(y - x + 1);
    cout << v2[lg][x] << "\n";
  }
  return 0;
}
