#include <bits/stdc++.h>
using namespace std;
long long pow(long long x, long long y) {
  long long res = 1;
  while (y > 0) {
    if (y & 1) res = ((res) * (x));
    res %= 1000000007;
    y = y >> 1;
    x = ((x) * (x));
  }
  return res;
}
long long power(long long x, long long y, long long p) {
  long long res = 1;
  x = x % p;
  while (y > 0) {
    if (y & 1) res = (res * x) % p;
    y = y >> 1;
    x = (x * x) % p;
  }
  return res;
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long n;
  cin >> n;
  vector<long long> v;
  long long a;
  vector<long long> pre;
  v.push_back(0);
  pre.push_back(0);
  for (long long i = 1; i <= n; ++i) {
    cin >> a;
    v.push_back(a);
    pre.push_back(pre[i - 1] + a);
  }
  long long k;
  cin >> k;
  long long b;
  for (long long i = 0; i < k; ++i) {
    cin >> a >> b;
    cout << (pre[b] - pre[a - 1]) / 10 << "\n";
  }
}
