#include <bits/stdc++.h>
using namespace std;
long long int power(long long int a, long long int b,
                    long long int m = 1000000007) {
  if (b == 0) return 1;
  if (b == 1) return a;
  long long int c = power(a, b / 2, m);
  if (b % 2 == 0) return ((c % m) * (c % m)) % m;
  return ((((c % m) * (c % m)) % m) * (a % m)) % m;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long int n, k, m, i, j, c = 0, cs = 0, t;
  t = 1;
  cin >> n;
  long long int a[n], p[n + 1];
  for (long long int i = 0; i < n; i++) {
    cin >> a[i];
  }
  p[0] = 0;
  for (long long int i = 1; i < n + 1; i++) {
    p[i] = p[i - 1] + a[i - 1];
  }
  cin >> t;
  string s;
  while (t--) {
    long long int l, r;
    cin >> l >> r;
    c = (p[r] - p[l - 1]) / 10;
    cout << c;
    if (t != 0) cout << "\n";
  }
  return 0;
}
