#include <bits/stdc++.h>
using namespace std;
const int inf = 1 << 30;
const long long INF = 1ll << 60;
const double pi = acos(-1);
const double eps = 1e-8;
const long long mod = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0}, dy[4] = {0, -1, 0, 1};
int n, m;
int main() {
  cin >> n >> m;
  vector<long long> dp(m + 1);
  long long res = 0;
  for (int j = 0; j < n; j++) {
    int x;
    cin >> x;
    vector<long long> DP(m + 1);
    (DP[x] += j + 1) %= mod;
    for (int j = 0; j <= m - x; j++) (DP[j + x] += dp[j]) %= mod;
    (res += DP[m] * (n - j)) %= mod;
    for (int j = 0; j <= m; j++) (dp[j] += DP[j]) %= mod;
  }
  cout << res << endl;
}
