#include <bits/stdc++.h>
using namespace std;
const long long int INF = 1e18 + 1;
const long long int MOD = 1000000007L;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long int n, s;
  cin >> n >> s;
  vector<long long int> a(n + 1);
  for (long long int i = 1; i <= (n); ++i) cin >> a[i];
  long long int dp[n + 1][s + 1];
  long long int dp1[n + 1][s + 1];
  memset(dp, 0, sizeof dp);
  memset(dp1, 0, sizeof dp);
  for (long long int i = 1; i <= (n); ++i) {
    for (long long int j = 1; j <= (s); ++j) {
      if (j > a[i])
        dp[i][j] = dp1[i - 1][j - a[i]];
      else if (j == a[i]) {
        dp[i][j] = i;
      }
      dp[i][j] %= MOD;
      dp1[i][j] = dp1[i - 1][j] + dp[i][j];
      dp1[i][j] %= MOD;
    }
  }
  long long int ans = 0;
  for (long long int i = 1; i <= (n); ++i) {
    ans += ((n - i + 1) * dp[i][s]) % MOD;
    ans %= MOD;
  }
  cout << ans << endl;
  ;
  return 0;
}
