#include <stdio.h>

int main() {
    while (1) {
        int n, q;
        // Entrada de n e q
        scanf("%d %d", &n, &q);

        if (n == 0 && q == 0) {
            break;
        }

        // Entrada do vetor v
        int v[n];
        for (int i = 0; i < n; i++) {
            scanf("%d", &v[i]);
        }

        // Calculando a soma prefixada (psum)
        int psum[n];
        psum[0] = v[0];
        for (int i = 1; i < n; i++) {
            psum[i] = psum[i - 1] + v[i];
        }

        // Processando as queries
        while (q > 0) {
            int l, r;
            scanf("%d %d", &l, &r);
            l--;
            r--;

            int tam = r - l + 1;
            int soma;

            if (l == 0) {
                soma = psum[r];
            } else {
                soma = psum[r] - psum[l - 1];
            }

            int resp = (tam - 1) * soma * 11;
            printf("%d\n", resp);

            q--;
        }
    }

    return 0;
}
