#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e15 + 0;
const long long mod = 1e9 + 7;
const long long N = 3e3 + 5;
long long dp[N][N], P[N][N];
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long n, sum;
  cin >> n >> sum;
  long long data[n + 5];
  for (long long i = 1; i <= n; i++) {
    cin >> data[i];
    dp[i][data[i]] = i;
  }
  for (long long i = 1; i <= n; i++) {
    for (long long j = 1; j <= sum; j++) {
      if ((j - data[i]) >= 0) {
        dp[i][j] += P[i - 1][j - data[i]];
      }
      P[i][j] = dp[i][j] + P[i - 1][j];
    }
  }
  long long ans = 0;
  for (long long i = 1; i <= n; i++) {
    long long temp = (dp[i][sum] * (n - i + 1)) % mod;
    ans += temp;
    ans %= mod;
  }
  cout << ans << '\n';
}
