#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 5, M = 1e6 + 5;
long long a[N];
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    a[i] += a[i - 1];
  }
  int q;
  cin >> q;
  while (q--) {
    int l, r;
    cin >> l >> r;
    cout << (a[r] - a[l - 1]) / 10 << "\n";
  }
  return 0;
}
