#include <bits/stdc++.h>
using namespace std;
int q, s, k, n, r, l, ot2[110000], step2[30];
pair<int, int> a[30][110000];
int main() {
  ios_base::sync_with_stdio(0);
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[0][i].first;
  step2[0] = 1;
  ot2[1] = 0;
  for (int i = 2; i <= n; i *= 2) {
    s++;
    step2[s] = i;
    ot2[i] = s;
  }
  cin >> q;
  int u = log2(n);
  for (int j = 1; j <= u; j++) {
    for (int i = 1; i <= n; i++) {
      if (i + step2[j - 1] <= n) {
        a[j][i].first =
            (a[j - 1][i].first + a[j - 1][i + step2[j - 1]].first) % 10;
        a[j][i].second =
            ((a[j - 1][i].second + a[j - 1][i + step2[j - 1]].second));
        if (a[j - 1][i].first + a[j - 1][i + step2[j - 1]].first >= 10)
          a[j][i].second++;
      } else {
        a[j][i].second = a[j - 1][i].second;
        a[j][i].first = a[j - 1][i].first;
      }
    }
  }
  cout << endl;
  for (int i = 1; i <= q; i++) {
    cin >> l >> r;
    cout << a[ot2[r - l + 1]][l].second << endl;
  }
  return 0;
}
