#include using namespace std; using ll = long long; //RSQ (0-indexed) template struct BIT { private: vector bit; int N; T _sum(int r){ r++; T res = 0; while(r > 0) res += bit[r-1], r -= r & -r; return res; } public: BIT (int n){ N = n; bit.resize(N);} BIT (vector &a) : BIT(a.size()) { for (int i=0; i= modc) x -= modc; return *this; } mint& operator-=(const mint& a) { if ((x += modc-a.x) >= modc) x -= modc; return *this; } mint& operator*=(const mint& a) { (x *= a.x) %= modc; return *this; } mint operator+(const mint& a) const { mint res(*this); return res+=a; } mint operator-(const mint& a) const { mint res(*this); return res-=a; } mint operator*(const mint& a) const { mint res(*this); return res*=a; } mint pow(ll t) const { if (!t) return 1; mint a = pow(t>>1); a *= a; if (t&1) a *= *this; return a; } mint inv() const {return pow(modc-2);} mint& operator/=(const mint& a){ return (*this) *= a.inv();} mint operator/(const mint& a) const { mint res(*this); return res/=a; } bool operator == (const mint& a) const{ return x == a.x;} bool operator != (const mint& a) const{ return x != a.x;} friend ostream& operator<<(ostream& os, const mint& m){ os << m.x; return os; } friend istream& operator>>(istream& ip, mint &m) { ll t; ip >> t; m = mint(t); return ip; } ll val(){ return x;} }; int main(){ cin.tie(nullptr); ios_base::sync_with_stdio(false); //dp(i, j) = i番目のプレイヤーの仮のスコアがjであるような場合の数 //k <= j //k+A_(i-1) <= j+A_i <= 1e5 //k = 0, 1, ..., min(j+A_i-A_(i-1), j)からの遷移(0<=j<=1e5-A_i) int N, M=1e5; cin >> N; vector A(N+1); for (int i = 1; i <= N; ++i) cin >> A[i]; BIT dp(M+1); for (int i=0; i<=M-A[1]; i++) dp.add(i, 1); for (int i=2; i<=N; i++){ BIT dp2(M+1); for (int j=0; j<=M-A[i]; j++){ dp2.add(j, dp.sum(0, min(j+A[i]-A[i-1], j))); } swap(dp, dp2); } mint ans = 0; cout << dp.sum(0, M) << endl; return 0; }