/*
MiYu原创, 转帖请注明 : 转载自 ______________白白の屋
http://www.cnblog.com/MiYu
Author By : MiYu
Test : 1
Program : 2227
*/
#include <iostream>
#include <algorithm>
using namespace std;
#define lowbit(x) (x&(-x))
int num[100005];
int numcopy[100005];
int hash[100005];
int com[100005];
int nCount = 1;
void add ( int x,int k )
{
while ( x <= nCount )
{
com[x] += k;
if ( com[x] >= 1000000007 ) com[x] %= 1000000007;
x += lowbit(x);
}
}
int sum ( int x )
{
int s = 0;
while ( x > 0 )
{
s += com[x];
if ( s >= 1000000007 ) s %= 1000000007;
x -= lowbit(x);
}
return s %= 1000000007;
}
int cmp (const void *a, const void *b)
{
return *((int*)a) - *((int*)b);
}
int sfind ( int x )
{
int *p = (int *)bsearch ( &x,hash+1,nCount+1,sizeof ( int ),cmp );
return p - hash;
}
int find(int num){
int top=1,bottom=nCount,mid=(top+bottom)/2,ans=mid;
while(num!=hash[ans]){
if(hash[mid]<=num){
top=(ans=mid)+1;
}else{
bottom=mid-1;
}
mid=(top+bottom)/2;
}
return ans;
}
inline bool scan_d(int &num) //整数输入
{
char in;bool IsN=false;
in=getchar();
if(in==EOF) return false;
while(in!='-'&&(in<'0'||in>'9')) in=getchar();
if(in=='-'){ IsN=true;num=0;}
else num=in-'0';
while(in=getchar(),in>='0'&&in<='9'){
num*=10,num+=in-'0';
}
if(IsN) num=-num;
return true;
}
int main ()
{
int N;
while ( scan_d ( N ) )
{
for ( int i = 0; i != N; ++ i )
scan_d ( num[i] ),numcopy[i] = num[i];
sort ( num, num + N );
memset ( com,0,sizeof (com) );
nCount = 1;
hash[1] = num[0];
for ( int i = 1; i < N; ++ i )
{
if ( num[i] != num[i-1] )
hash[++nCount] = num[i];
}
for ( int i = 0; i < N; ++ i )
{
int pos = find ( numcopy[i] );
int res = sum ( pos ) + 1;
add ( pos,res );
}
cout << sum ( nCount ) << endl;
}
return 0;
}