#include <bits/stdc++.h>
using namespace std;
long long gcd(int x, int y) { return (x % y) ? gcd(y, x % y) : y; }
long long lcm(long long x, long long y) { return x / gcd(x, y) * y; }
using Graph = vector<vector<int>>;
long long inf = 300000000000000000;
const double PI = 3.14159265358979323846;
int main() {
  int n, s;
  cin >> n >> s;
  long long p = 1000000007;
  long long dp[n + 1][s + 1];
  for (int i = 0; i < (int)(n + 1); i++)
    for (int j = 0; j < (int)(s + 1); j++) dp[i][j] = 0;
  int a[n];
  for (int i = 0; i < (int)(n); i++) cin >> a[i];
  for (int i = 0; i < (int)(n); i++) {
    for (int j = 0; j < (int)(s + 1); j++) {
      if (a[i] + j <= s)
        dp[i + 1][a[i] + j] = (dp[i][j] + dp[i + 1][a[i] + j]) % p;
      dp[i + 1][j] = (dp[i][j] + dp[i + 1][j]) % p;
    }
    if (a[i] <= s) dp[i + 1][a[i]] = (dp[i + 1][a[i]] + 1) % p;
    dp[i + 1][0] = (1 + dp[i + 1][0]) % p;
  }
  long long ans = 0;
  for (int i = 0; i < (int)(n); i++) {
    ans = (ans + dp[i + 1][s]) % p;
  }
  cout << ans << endl;
}
