#include <bits/stdc++.h>
using namespace std;
const int N = 200005;
char en = '\n';
int inf = 1e9;
int mod = 1e9 + 7;
int power(int x, int n, int mod) {
  int res = 1;
  x %= mod;
  while (n) {
    if (n & 1) res = (res * x) % mod;
    x = (x * x) % mod;
    n >>= 1;
  }
  return res;
}
int dp[3005][3005];
int arr[3005];
int n;
int recur(int pos, int rem) {
  if (rem < 0) {
    return 0;
  }
  if (rem == 0) {
    return pos - 1;
  }
  if (pos == n + 1) return 0;
  int &ans = dp[pos][rem];
  if (ans != -1) return ans;
  ans = recur(pos + 1, rem - arr[pos]) + recur(pos + 1, rem);
  if (ans >= mod) ans -= mod;
  return ans;
}
int recur2(int pos, int rem) {
  if (rem < 0) {
    return 0;
  }
  if (rem == 0) {
    return 1;
  }
  if (pos == n + 1) return 0;
  int &ans = dp[pos][rem];
  if (ans != -1) return ans;
  ans = recur2(pos + 1, rem - arr[pos]) + recur2(pos + 1, rem);
  if (ans >= mod) ans -= mod;
  return ans;
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int s;
  cin >> n >> s;
  for (int i = 1; i <= n; i++) cin >> arr[i];
  memset(dp, -1, sizeof(dp));
  int res = 0;
  for (int i = 1; i <= n; i++) {
    res += (n + 1) * i % mod * recur2(i + 1, s - arr[i]) % mod;
    if (res >= mod) res -= mod;
  }
  memset(dp, -1, sizeof(dp));
  for (int i = 1; i <= n; i++) {
    res -= i * recur(i + 1, s - arr[i]) % mod;
    if (res < 0) res += mod;
  }
  cout << res << en;
  return 0;
}
