#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
const int MAX = 262144;
const int END = 200000;
const int INF = 1e9 + 7;
int n, q;
int tree[2 * MAX];
void update(int idx, int val) {
  idx += MAX;
  tree[idx] = val;
  idx /= 2;
  while (idx > 0) {
    tree[idx] = tree[idx * 2] + tree[idx * 2 + 1];
    idx /= 2;
  }
}
int sum(int l, int r, int node_l, int node_r, int node) {
  if (r < node_l || node_r < l) return 0;
  if (l <= node_l && node_r <= r) return tree[node];
  int mid = (node_l + node_r) / 2;
  return sum(l, r, node_l, mid, node * 2) +
         sum(l, r, mid + 1, node_r, node * 2 + 1);
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < 2 * MAX; i++) tree[i] = 0;
  for (int i = 1; i <= n; i++) {
    int x;
    scanf("%d", &x);
    update(i, x);
  }
  scanf("%d", &q);
  for (int i = 0; i < q; i++) {
    int a, b;
    scanf("%d %d", &a, &b);
    printf("%d\n", sum(a, b, 0, MAX - 1, 1) / 10);
  }
}
