#include <bits/stdc++.h>
using namespace std;
void solve() {
  long long n;
  cin >> n;
  vector<long long> a(n);
  for (long long i = 0; i < n; i++) cin >> a[i];
  long long p[n];
  p[0] = a[0];
  for (long long i = 1; i < n; i++) {
    p[i] = p[i - 1] + a[i];
  }
  long long q;
  cin >> q;
  for (long long i = 0; i < q; i++) {
    long long aa, b;
    cin >> aa >> b;
    aa--;
    b--;
    cout << (p[b] - p[aa] + a[aa]) / 10 << "\n";
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
