#include <iostream>
#include <vector>
#include <set>
#include <map>
using namespace std;

const int MOD = 1e9 + 7;
int main() {
	cin.tie(0);
	ios_base::sync_with_stdio(0);
	
	int n;
	cin >> n;
	vector<int> x(n);
	set<int> x_set;
	map<int, int> x_map_idx;
	
	for(int &val: x){
		cin >> val;
		x_set.insert(val);
	}
	for(int val: x_set){
		x_map_idx[val] = x_map_idx.size() + 1;
	}
	for(int &val: x){
		val = x_map_idx[val];
	}
	
	vector<int> BITS(n + 1);
	auto update = [&](int pos, int val){
		while(pos < BITS.size()){
			BITS[pos] = (BITS[pos] + val) % MOD;
			pos += pos & -pos;
		}
	};
	
	auto query = [&](int pos){
		int ans = 0;
		while(pos){
			ans = (ans + BITS[pos]) % MOD;
			pos -= pos & -pos;
		}
		return ans;
	};
	
	int ans = 0;
	for(auto &val: x){
		int end_with_val_cnt = query(val - 1) + 1;
		ans = (ans + end_with_val_cnt) % MOD;
		update(val, end_with_val_cnt);
	}
	
	cout << ans << '\n';
	return 0;
}