#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<long long> s(n + 1, 0);
  for (int i = (1); i < (n + 1); ++i) cin >> s[i];
  for (int i = (1); i < (n + 1); ++i) s[i] += s[i - 1];
  int q;
  cin >> q;
  while (q--) {
    int l, r;
    cin >> l >> r;
    --l;
    --r;
    cout << (s[r + 1] - s[l]) / 10 << '\n';
  }
  return 0;
}
