#include <bits/stdc++.h>
using namespace std;
const long long INF = (long long)998244353;
const long long MOD = (long long)1e9 + 7;
const int MAXN = 3005;
int n, tgt, a[MAXN];
long long dp[MAXN][MAXN], sum[MAXN];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> tgt;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    for (int j = a[i]; j <= tgt; j++) {
      dp[i][j] = sum[j - a[i]];
    }
    dp[i][a[i]] = (dp[i][a[i]] + i) % MOD;
    for (int j = a[i]; j <= tgt; j++) {
      sum[j] = (sum[j] + dp[i][j]) % MOD;
    }
  }
  long long ans = 0;
  for (int i = 1; i <= n; i++) {
    ans = (ans + dp[i][tgt] * (n - i + 1)) % MOD;
  }
  cout << ans << '\n';
  return 0;
}
