#include <bits/stdc++.h>
using namespace std;
struct Edge {
  int from, to, dist;
  Edge(int u, int v, int d) : from(u), to(v), dist(d) {}
};
int a[100007];
int n, q;
int l, r;
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    a[i] += a[i - 1];
  }
  cin >> q;
  for (int i = 1; i <= q; i++) {
    cin >> l >> r;
    cout << (a[r] - a[l - 1]) / 10 << endl;
  }
  return 0;
}
