#include<bits/stdc++.h>
using namespace std;
const int mod=1000000009;
int n,t[100002],ans;
struct book { int s,i; }b[100002];
inline int read ( void )
{
int x=0;char ch=getchar();bool f=true;
while ( !isdigit(ch) ) f^=(ch=='-'),ch=getchar();
for ( x=ch-48;isdigit(ch=getchar()); ) x=(x<<1)+(x<<3)+ch-48;
return f ? x : -x;
}
inline bool cmp ( const book &b1,const book &b2 ) { return (b1.s<b2.s)|(b1.s==b2.s)&(b1.i<b2.i); }
inline void add ( int x,int y ) { for (;x<=n;x+=x&(-x)) t[x]=(t[x]+y)%mod; }
inline void sum ( int x,int &ans ) { ans=0;for (;x;x-=x&-x) ans=(ans+t[x])%mod; }
int main()
{
n=read();
for ( int i=1;i<=n;i++ ) b[i].s=b[i-1].s+read(),b[i].i=i;
sort(b+1,b+n+1,cmp);add(1,1);sum(1,ans);
for ( int i=1;i<=n;i++ )
{
if ( b[i].s<0 ) continue;
sum(b[i].i,ans);add(b[i].i,ans);
if ( b[i].i==n ) return !printf("%d\n",ans);
}
return puts("0");
}