#include <bits/stdc++.h>
using namespace std;
long long n, s, a, ans, M = 1e9, d[3005] = {1};
int main() {
  cin >> n >> s;
  while (n--) {
    cin >> a;
    if (s >= a) (ans += d[s - a] * (n + 1)) %= M;
    for (long long i = s - a - 1; i >= 0; i--) (d[i + a] += d[i]) %= M;
    d[0]++;
  }
  cout << ans;
  return 0;
}
