#include <bits/stdc++.h>
using namespace std;
int n, q;
int a[100005];
int s[100005];
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i];
  s[0] = 0;
  for (int i = 1; i <= n; i++) s[i] = s[i - 1] + a[i];
  cin >> q;
  for (int i = 1; i <= q; i++) {
    int x, y;
    cin >> x >> y;
    int sum = s[y] - s[x - 1];
    int ans = sum / 10;
    cout << ans << endl;
  }
  return 0;
}
