#include <bits/stdc++.h>
int read() {
  int x = 0;
  int zf = 1;
  char ch = ' ';
  while (ch != '-' && (ch < '0' || ch > '9')) ch = getchar();
  if (ch == '-') zf = -1, ch = getchar();
  while (ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
  return x * zf;
}
long long qzh[500005];
int main() {
  int n = read();
  for (int i = 1; i <= n; ++i) qzh[i] = read() + qzh[i - 1];
  int m = read();
  while (m--) {
    int l = read(), r = read();
    long long ans = (qzh[r] - qzh[l - 1]) / 10;
    printf("%I64d\n", ans);
  }
  return 0;
}
