#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5 + 10;
int n, a[MAXN], q, f[MAXN][25], g[MAXN][25], l, r;
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  for (int i = 1; i < n; i++) {
    if (a[i] + a[i + 1] > 9) f[i][1] = 1;
    g[i][1] = (a[i] + a[i + 1]) % 10;
  }
  for (int i = 2; i < 25; i++)
    for (int j = 1; j <= n - (1 << i) + 1; j++) {
      f[j][i] = f[j][i - 1] + f[j + (1 << (i - 1))][i - 1];
      if (g[j][i - 1] + g[j + (1 << (i - 1))][i - 1] > 9) ++f[j][i];
      g[j][i] = (g[j][i - 1] + g[j + (1 << (i - 1))][i - 1]) % 10;
    }
  scanf("%d", &q);
  while (q--) {
    scanf("%d%d", &l, &r);
    int len = log2(r - l + 1);
    printf("%d\n", f[l][len]);
  }
  return 0;
}
