using System;

namespace Cetvrti
{
    class Program
    {
            static void Main(string[] args)
            {
                int s = 0;
                string[] unos = Console.ReadLine().Split();
                int n = int.Parse(unos[0]);
                int k = int.Parse(unos[1]);
                int[] A = new int[n];
                unos = Console.ReadLine().Split();
                for (int i = 0; i < n; i++)
                    A[i] = int.Parse(unos[i]);
                if (k == 0)
                    for (int i = 0; i < n; i++)
                        s += A[i];
                else
                    for (int i = 0; i < n; i++)
                        for (int j = n; j > i; j--)
                            for (int x = i; x < j; x++)
                                s += A[x];
                Console.WriteLine((s % (Math.Pow(10,9) + 7)));
            }
    }
}