#include <bits/stdc++.h>
using namespace std;
string to_string(string s) { return '"' + s + '"'; }
string to_string(char c) {
  string s = "'";
  s += c;
  return s + "'";
}
string to_string(const char* s) { return to_string((string)s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto& x : v) {
    if (!first) res += ", ";
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
istream_iterator<string> eos;
void dbg_out(istream_iterator<string> it) { cerr << endl; }
template <typename Head, typename... Tail>
void dbg_out(istream_iterator<string> it, Head H, Tail... T) {
  cerr << *it << " = " << to_string(H);
  if (++it != eos) cerr << ", ";
  dbg_out(it, T...);
}
pair<long long, long long> dir[8] = {{-1, 0}, {1, 0},   {0, -1}, {0, 1},
                                     {1, 1},  {-1, -1}, {-1, 1}, {1, -1}};
const long long inf = (1LL << 60), mod = 1e9 + 7, nn = 3003;
bool dp[nn][nn];
long long ans = 0, n;
void find_subsets_min_max_index(long long arr[], long long i, long long sum,
                                long long mn, long long mx) {
  if (i == 0 && sum != 0 && dp[0][sum]) {
    mx = max(mx, i);
    mn = min(mn, i);
    ans = (ans + (mn + 1) * (n - 1 - mx + 1)) % mod;
    return;
  }
  if (i == 0 && sum == 0) {
    ans = (ans + (mn + 1) * (n - 1 - mx + 1)) % mod;
    return;
  }
  if (dp[i - 1][sum]) {
    find_subsets_min_max_index(arr, i - 1, sum, mn, mx);
  }
  if (sum >= arr[i] && dp[i - 1][sum - arr[i]]) {
    find_subsets_min_max_index(arr, i - 1, sum - arr[i], min(mn, i),
                               max(mx, i));
  }
}
void find_subsets(long long arr[], long long n, long long sum) {
  for (long long i = 0; i < n; ++i) {
    dp[i][0] = true;
  }
  dp[0][arr[0]] = true;
  for (long long i = 1; i < n; ++i) {
    for (long long j = 1; j <= sum; ++j) {
      dp[i][j] =
          (arr[i] <= j) ? dp[i - 1][j] || dp[i - 1][j - arr[i]] : dp[i - 1][j];
    }
  }
  if (dp[n - 1][sum] == false) {
    return;
  }
  find_subsets_min_max_index(arr, n - 1, sum, n, -1);
}
void solve() {
  long long s;
  cin >> n >> s;
  long long a[n];
  for (long long i = 0; i < n; i++) cin >> a[i];
  find_subsets(a, n, s);
  cout << ans << "\n";
}
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long T = 1;
  for (long long tc = 1; tc <= T; tc++) {
    solve();
  }
  return 0;
}
