#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
const long long INF = (long long)1000000007 * 1000000007;
const long double eps = 1e-8;
const long double pi = acos(-1.0);
int dx[4] = {1, -1, 0, 0};
int dy[4] = {0, 0, 1, -1};
template <int mod>
struct ModInt {
  long long x;
  ModInt() : x(0) {}
  ModInt(long long y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}
  explicit operator int() const { return x; }
  ModInt &operator+=(const ModInt &p) {
    if ((x += p.x) >= mod) x -= mod;
    return *this;
  }
  ModInt &operator-=(const ModInt &p) {
    if ((x += mod - p.x) >= mod) x -= mod;
    return *this;
  }
  ModInt &operator*=(const ModInt &p) {
    x = (int)(1LL * x * p.x % mod);
    return *this;
  }
  ModInt &operator/=(const ModInt &p) {
    *this *= p.inverse();
    return *this;
  }
  ModInt operator-() const { return ModInt(-x); }
  ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }
  ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }
  ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }
  ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }
  bool operator==(const ModInt &p) const { return x == p.x; }
  bool operator!=(const ModInt &p) const { return x != p.x; }
  ModInt inverse() const {
    int a = x, b = mod, u = 1, v = 0, t;
    while (b > 0) {
      t = a / b;
      a -= t * b;
      swap(a, b);
      u -= t * v;
      swap(u, v);
    }
    return ModInt(u);
  }
  ModInt power(long long p) const {
    int a = x;
    if (p == 0) return 1;
    if (p == 1) return ModInt(a);
    if (p % 2 == 1)
      return (ModInt(a) * ModInt(a)).power(p / 2) * ModInt(a);
    else
      return (ModInt(a) * ModInt(a)).power(p / 2);
  }
  ModInt power(const ModInt p) const { return ((ModInt)x).power(p.x); }
  friend ostream &operator<<(ostream &os, const ModInt<mod> &p) {
    return os << p.x;
  }
  friend istream &operator>>(istream &is, ModInt<mod> &a) {
    long long x;
    is >> x;
    a = ModInt<mod>(x);
    return (is);
  }
};
using modint = ModInt<mod>;
int n, S;
int a[3010];
modint dp[3010][3010];
void solve() {
  cin >> n >> S;
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = n - 1; i >= 0; i--) {
    dp[i][0] = 1;
    for (int j = 0; j < S + 1; j++) {
      dp[i][j] += dp[i + 1][j];
    }
    if (a[i] <= S) dp[i][a[i]] += 1;
    for (int j = 0; j < S + 1; j++) {
      if (a[i] + j <= S) dp[i][a[i] + j] += dp[i + 1][j];
    }
  }
  modint ans = 0;
  for (int i = 0; i < n; i++) {
    ans += dp[i][S];
  }
  cout << ans << endl;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(50);
  solve();
}
