#include <bits/stdc++.h>
using namespace std;
pair<long long, long long> t[400000];
long long a[100000];
long long n = 0;
long long q = 0;
long long l = 0, r = 0;
void build(long long v, long long tl, long long tr) {
  if (tl == tr)
    t[v].first = a[tl];
  else {
    long long tm = (tl + tr) / 2;
    build(v * 2, tl, tm);
    build(v * 2 + 1, tm + 1, tr);
    t[v].first = (t[v * 2].first + t[v * 2 + 1].first) % 10;
    if (t[v * 2].first + t[v * 2 + 1].first >= 10) t[v].second++;
    t[v].second += t[v * 2].second + t[v * 2 + 1].second;
  }
}
pair<long long, long long> sum(long long v, long long tl, long long tr,
                               long long l, long long r) {
  if (l > r) return {0, 0};
  if (l == tl && r == tr) return t[v];
  long long tm = (tl + tr) / 2;
  pair<long long, long long> p1 = sum(v * 2, tl, tm, l, min(r, tm));
  pair<long long, long long> p2 = sum(v * 2 + 1, tm + 1, tr, max(l, tm + 1), r);
  return {(p1.first + p2.first) % 10,
          p1.second + p2.second + ((p1.first + p2.first) >= 10)};
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n;
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
  }
  build(1, 0, n - 1);
  cin >> q;
  while (q--) {
    cin >> l >> r;
    l--;
    r--;
    cout << sum(1, 0, n - 1, l, r).second << endl;
  }
  return 0;
}
