#include <iostream>
#include <algorithm>
#include <vector>
#include <set>

using namespace std;

typedef unsigned long long ull;
typedef unsigned u;

ull a[200001] = {0};
const ull moduo = 1000000007;
#define m(x) if ((x) >= moduo) (x) -= moduo;

int main()
{
	u n, k;
    	cin >> n >> k;
        	vector<vector<unsigned long long>> dp1(n, vector<unsigned long long>(n)), dp2(n, vector<unsigned long long>(n));
            	vector<vector<unsigned long long>> *pr = &dp1, *tr = &dp2;
                	for (int i = 0; i < n; i++)
                    		cin >> a[i];
                            	{
                                		auto &p = *pr;
                                        		for (int i = 0; i < n; i++)
                                                			for (int j = i; j < n; j++)
                                                            			{
                                                                        				ull suma = 0;
                                                                                        				for (int ii = i; ii <= j; ii++)
                                                                                                        				{
                                                                                                                        					suma += a[ii];
                                                                                                                                            					m(suma)
                                                                                                                                                                				}
                                                                                                                                                                                				p[i][j] = suma;
                                                                                                                                                                                                			}
                                                                                                                                                                                                            	}
                                                                                                                                                                                                                	if (!k)
                                                                                                                                                                                                                    	{
                                                                                                                                                                                                                        		cout << (*pr)[0][n-1];
                                                                                                                                                                                                                                		return 0;
                                                                                                                                                                                                                                        	}
                                                                                                                                                                                                                                            	while (--k)
                                                                                                                                                                                                                                                	{
                                                                                                                                                                                                                                                    		auto &p = *pr;
                                                                                                                                                                                                                                                            		auto &t = *tr;
                                                                                                                                                                                                                                                                    		for (int i = 0; i < n; i++)
                                                                                                                                                                                                                                                                            		{
                                                                                                                                                                                                                                                                                    			ull suma = 0;
                                                                                                                                                                                                                                                                                                			for (int j = i; j < n; j++)
                                                                                                                                                                                                                                                                                                            			{
                                                                                                                                                                                                                                                                                                                        				for (int ii = i; ii <= j; ii++)
                                                                                                                                                                                                                                                                                                                                        				{
                                                                                                                                                                                                                                                                                                                                                        					suma += p[ii][j];
                                                                                                                                                                                                                                                                                                                                                                            					m(suma)
                                                                                                                                                                                                                                                                                                                                                                                                				}
                                                                                                                                                                                                                                                                                                                                                                                                                				t[i][j] = suma;
                                                                                                                                                                                                                                                                                                                                                                                                                                			}
                                                                                                                                                                                                                                                                                                                                                                                                                                            		}
                                                                                                                                                                                                                                                                                                                                                                                                                                                    		swap(pr, tr);
                                                                                                                                                                                                                                                                                                                                                                                                                                                            	}
                                                                                                                                                                                                                                                                                                                                                                                                                                                                	ull suma = 0;
                                                                                                                                                                                                                                                                                                                                                                                                                                                                    	for (int i = 0; i < n; i++)
                                                                                                                                                                                                                                                                                                                                                                                                                                                                        		for (int j = i; j < n; j++)
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                		{
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        			suma += (*pr)[i][j];
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    			m(suma)
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                		}
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        	cout << suma;
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            }