#include <bits/stdc++.h>
using namespace std;
void solve() {
  int n;
  cin >> n;
  int arr[n];
  for (int i = 0; i < n; i++) cin >> arr[i];
  vector<int> a(n + 1);
  for (int i = 1; i <= n; i++) {
    a[i] = a[i - 1] + arr[i - 1];
  }
  int m;
  cin >> m;
  for (int i = 0; i < m; i++) {
    int l, r;
    cin >> l >> r;
    l--;
    cout << (a[r] - a[l]) / 10 << endl;
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  int t = 1;
  while (t--) solve();
  return 0;
}
