#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n, q;
  cin >> n;
  vector<int> v(n), pre(n + 1);
  for (int i = 0; i < n; ++i) {
    cin >> v[i];
    pre[i + 1] = pre[i] + v[i];
  }
  cin >> q;
  while (q--) {
    int l, r;
    cin >> l >> r;
    cout << (pre[r] - pre[l - 1]) / 10 << '\n';
  }
}
