#include <bits/stdc++.h>
using namespace std;
const int MAXN = 4e5 + 10;
int a[MAXN], c[MAXN];
int lowbit(int x) { return x & -x; }
int getsum(int x) {
  int ans = 0;
  for (int i = x; i > 0; i -= lowbit(i)) ans += c[i];
  return ans;
}
void update(int x, int y, int n) {
  for (int i = x; i <= n; i += lowbit(i)) c[i] += y;
}
int main() {
  int i, n, k, j, x, y;
  memset(c, 0, sizeof(c));
  scanf("%d", &n);
  for (i = 1; i <= n; i++) {
    scanf("%d", &x);
    update(i, x, n);
  }
  scanf("%d", &k);
  for (j = 1; j <= k; j++) {
    scanf("%d%d", &x, &y);
    printf("%d\n", (getsum(y) - getsum(x - 1)) / 10);
  }
}
