import std.stdio, std.string, std.conv, std.range;
import std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, std.random, core.bitop;

enum inf = 1_001_001_001;
enum infl = 1_001_001_001_001_001_001L;
enum mod = 1_000_000_007L;

void main() {
    int N, K;
    scan(N, K);
    auto a = readln.split.to!(int[]);

    auto dp = new ModInt[][](N + 1, K + 1);
    dp[0][0] = 1;

    foreach (i ; 1 .. N + 1) {
        foreach (j ; 0 .. K + 1) {
            dp[i][j] = dp[i - 1][j];
            if (j > 0) dp[i][j] += dp[i][j - 1];
            if (j - a[i - 1] - 1 >= 0) dp[i][j] -= dp[i - 1][j - a[i - 1] - 1];
        }
    }

    auto ans = dp[N][K];
    writeln(ans);
}


struct ModInt {
    long value = 0;
    long mod = 1_000_000_007L;

    this(long value, long mod = 1_000_000_007L) {
        this.mod = mod;
        this.value = (value % mod);
        if (this.value < 0) this.value += mod;
    }

    void opAssign(long x) {
        value = x % mod;
        if (value < 0) value += mod;
    }

    ModInt opBinary(string op)(const ModInt rhs){
        static if (op == "+") {
            auto lhs = this;
            lhs.value += rhs.value;
            if (lhs.value >= mod) lhs.value -= mod;
            return lhs;
        }
        static if (op == "-") {
            auto lhs = this;
            lhs.value -= rhs.value;
            if (lhs.value < 0) lhs.value += mod;
            return lhs;
        }
        static if (op == "*") {
            auto lhs = this;
            (lhs.value *= rhs.value) %= mod;
            return lhs;
        }
    }

    ModInt opBinary(string op)(long rhs){
        rhs %= mod;
        if (rhs < 0) rhs += mod;

        static if (op == "+") {
            auto lhs = this;
            lhs.value += rhs;
            if (lhs.value >= mod) lhs.value -= mod;
            return lhs;
        }
        static if (op == "-") {
            auto lhs = this;
            lhs.value -= rhs;
            if (lhs.value < 0) lhs.value += mod;
            return lhs;
        }
        static if (op == "*") {
            auto lhs = this;
            (lhs.value *= rhs) %= mod;
            return lhs;
        }
    }

    bool opEquals(ModInt a, ModInt b) {
        return a.value == b.value;
    }

    bool opEquals(T)(const T rhs) {
        long x = rhs % mod;
        if (x < 0) x += mod;
        return this.value == x;
    }

    void opOpAssign(string op)(const ModInt rhs) {
        static if (op == "+") {
            this.value += rhs.value;
            if (this.value >= mod) this.value -= mod;
        }
        static if (op == "-") {
            this.value -= rhs.value;
            if (this.value < 0) this.value += mod;
        }
        static if (op == "*") {
            (this.value *= rhs.value) %= mod;
        }
    }

    void opOpAssign(string op)(long rhs) {
        rhs %= mod;
        if (rhs < 0) rhs += mod;

        static if (op == "+") {
            this.value += rhs;
            if (this.value >= mod) this.value -= mod;
        }
        static if (op == "-") {
            this.value -= rhs;
            if (this.value < 0) this.value += mod;
        }
        static if (op == "*") {
            (this.value *= rhs) %= mod;
        }
    }

    string toString() {
        import std.conv : to;
        return value.to!string;
    }
}





void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

bool chmin(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x > arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}

bool chmax(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x < arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}


Measured memory_bytes: 161660