#include <bits/stdc++.h>
using namespace std;
long long int nn1[1000], nn0[1000];
long long int s[100005], s1[100005];
int main() {
  long long int n, i, q, l, r, ans;
  cin >> n;
  for (i = 1; i <= n; i++) {
    cin >> s[i];
    s1[i] = s[i] + s1[i - 1];
  }
  cin >> q;
  for (i = 1; i <= q; i++) {
    cin >> l >> r;
    ans = (s1[r] - s1[l - 1]) / 10;
    cout << ans << endl;
  }
  return 0;
}
