#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5, Q = 0, mod = 1e9 + 7, MOD = 0;
struct UnionFind {
  int ran, pad, tam;
};
int n, a[N], acu[N], q, l[N], r[N];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
  cin >> q;
  for (int i = 0; i < n; i++) acu[i] = a[i];
  for (int i = 1; i < n; i++) acu[i] += acu[i - 1];
  for (int i = 0; i < q; i++) {
    cin >> l[i] >> r[i];
    l[i]--;
    r[i]--;
    long long x = 0;
    x = acu[r[i]];
    if (l[i]) x -= acu[l[i] - 1];
    x /= 10;
    cout << x << "\n";
  }
  return 0;
}
