#include <bits/stdc++.h>
using namespace std;
long long int GC(long long int a, long long int b) {
  if (b == 0)
    return a;
  else
    return GC(b, a % b);
}
long long int inv_gc(long long int a, long long int b) {
  return a / GC(a, b) * b;
}
long long int Ceil(long long int a, long long int b) {
  return a / b + (a % b != 0);
}
long long int fastModExp(long long int a, long long int b) {
  long long int res = 1;
  while (b > 0) {
    if (b & 1) res = (res * a) % 1000000007;
    a = (a * a) % 1000000007;
    b = b >> 1;
  }
  return res;
}
map<int, int> par, rk;
void make_set(int n) {
  for (int i = 1; i <= n; i++) {
    par[i] = i;
    rk[i] = 1;
  }
}
int find(int x) {
  if (x == par[x]) return x;
  int p = find(par[x]);
  par[x] = p;
  return p;
}
int uni(int x, int y) {
  int p1 = find(x);
  int p2 = find(y);
  if (p1 == p2) return 0;
  if (rk[p1] > rk[p2]) {
    par[p2] = p1;
    rk[p1] += rk[p2];
  } else {
    par[p1] = p2;
    rk[p2] += rk[p1];
  }
  return 1;
}
bool sortinrev(const pair<int, int> &a, const pair<int, int> &b) {
  return (a.first > b.first);
}
bool sortbysec(const pair<int, int> &a, const pair<int, int> &b) {
  return (a.second < b.second);
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n, x, l, r;
  cin >> n;
  int v[n + 1], sum[n + 1];
  sum[0] = 0;
  for (int i = 1; i <= n; i++) {
    cin >> v[i];
    sum[i] = sum[i - 1] + v[i];
  }
  int ans[n + 1];
  ans[1] = 0;
  for (int i = 2; i <= n; i++) {
    ans[i] = sum[i] / 10;
  }
  int t;
  cin >> t;
  while (t--) {
    cin >> l >> r;
    cout << (sum[r] - sum[l - 1]) / 10 << endl;
  }
  return 0;
}
