#include<bits/stdc++.h>
# define endl            '\n'
# define clr(x,a)        memset(x,a,sizeof(x))
# define PI              3.14159265358979323846
# define vi              vector<int>
# define fo(i,n)         for(int i=1;i<=n;i++)
# define all(a)          a.begin(), a.end()
# define deb(x)          cout<<#x<<" = "<<x<<endl;
# define pb              push_back
# define sc              scanf
# define pr              printf
# define tc              int t; cin>>t; while(t--)
typedef long long ll;
using namespace std;

const int mxN=200006, mxM=1000006, mod=1e9+7;
int n, a[mxN], ps[mxN], k;

int f(int l, int r, int k){
   if(k==0)
      return (ps[r]-ps[l-1]);
   ll ret=0;
   for(int i=l; i<=r; i++){
      for(int j=i; j<=r; j++)
         ret=(ret+f(i,j,k-1))%mod;
   }
   return ret;
}

int main(){
   sc("%d %d", &n, &k);
   for(int i=1; i<=n; i++){
      sc("%d", &a[i]);
      ps[i]=ps[i-1]+a[i];
   }


   cout<<f(1,n,k)<<endl;

   return 0;
}