#include <bits/stdc++.h>
using namespace std;
long long n, s;
long long a[3001], dp[3001][3001];
signed main() {
  cin.tie(0);
  cout.tie(0);
  ios_base::sync_with_stdio(false);
  cin >> n >> s;
  for (long long i = 1; i <= n; i++) {
    cin >> a[i];
  }
  long long ans = 0;
  for (long long i = 1; i <= n; i++) {
    for (long long j = 0; j <= s; j++)
      dp[i][j] = dp[i - 1][j] + ((j >= a[i]) ? dp[i - 1][j - a[i]] : 0),
      dp[i][j] %= 1000000007;
    dp[i][a[i]] += i;
    ans += dp[i][s];
    ans %= 1000000007;
  }
  cout << ans;
}
