using System;

namespace ConsoleApp65
{
    class Program
    {
     
        static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split();
            int n = int.Parse(s[0]);
            int k = int.Parse(s[1]);
            int[] a = new int[n];
            int suma = 0;
            string[] s2 = Console.ReadLine().Split();
            for (int j = 0; j < n; j++) {
                a[j] = int.Parse(s2[j]);
                suma += a[j];
                suma %= (1000000000 + 7);

            }

            if (k == 0) 
                Console.WriteLine(suma);
            
           
        }
    } 
}