import java.util.Scanner;

public class Concatena {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        while (true) {
            // Entrada de n e q
            int n = scanner.nextInt();
            int q = scanner.nextInt();

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

            // Entrada do vetor v
            int[] v = new int[n];
            for (int i = 0; i < n; i++) {
                v[i] = scanner.nextInt();
            }

            // Calculando a soma prefixada (psum)
            int[] psum = new int[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 = scanner.nextInt() - 1;
                int r = scanner.nextInt() - 1;
                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;
                System.out.println(resp);

                q--;
            }
        }

        scanner.close();
    }
}
