using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BUG
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] niz, niz2;
            double Sum = 0;
            niz = Console.ReadLine().Split();
            int n = int.Parse(niz[0]);
            int k = int.Parse(niz[1]);
            int[] A = new int[n];
            niz2 = Console.ReadLine().Split();
            for (int i = 0; i < n; i++)
                A[i] = int.Parse(niz2[i]);
            if (k == 0)
                for (int i = 0; i < n; i++)
                    Sum += A[i];
            else
            {
                for (int j = 0; j < n; j++)
                    for (int m = n; m > j; m--)
                        for (int i = j; i < m; i++)
                            Sum += A[i];
            }
            Sum %= (Math.Pow(10, 9) + 7);
            Console.WriteLine(Sum.ToString());
            Console.ReadKey();
        }
    }
}