#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int a[n];
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 1; i < n; i++) {
    a[i] = a[i] + a[i - 1];
  }
  int q;
  cin >> q;
  int l, r;
  for (int i = 0; i < q; i++) {
    cin >> l >> r;
    int x;
    if (l > 1)
      x = a[r - 1] - a[l - 2];
    else if (l == 1)
      x = a[r - 1];
    x = x / 10;
    cout << x << "\n";
  }
  return 0;
}
