#include <iostream>
#include <cstdio>
#include <vector>
#include <map>
#include <cstdlib>

using namespace std;

const int maxn = 1 << 17;
const int mod = 1e9 + 7;

int n;
vector<int> a;

int fastsolve() {
	vector<int> sum(n + 1);
	map<int, int> mp;
	int res = 0;
	for (int i = 0; i < n; i++) {
		sum[i + 1] = (sum[i] * 2 + 2) % mod;
		if (mp.count(a[i])) {
			sum[i + 1] = (sum[i + 1] - sum[mp[a[i]]] - 1) % mod;
		}
		mp[a[i]] = i;
		res = (res + sum[i + 1]) % mod;
	}
	return res;
}

int slowsolve() {
	int ans = 0;
	for (int i = 0; i < n; i++) {
		vector<int> dp(n + 1);
		map<int, int> mp;
		dp[i] = 1;
		for (int j = i; j < n; j++) {
			dp[j + 1] = dp[j] * 2 % mod;
			if (mp.count(a[j])) dp[j + 1] = (dp[j + 1] + mod - dp[mp[a[j]]]) % mod;
			ans = (ans + dp[j + 1]) % mod;
			mp[a[j]] = j;
		}
	}
	return ans;
}

void gen() {
	n = rand() % 10 + 1;
	a.resize(n);
	for (int i = 0; i < n; i++) a[i] = rand() % n + 1;
}

void stress(bool f) {
	if (!f) return;
	for (int it = 0;; it++) {
		cerr << it << endl;
		gen();
		int ans1 = fastsolve();
		int ans2 = slowsolve();
		if (ans1 != ans2) {
			fastsolve();
			cout << ans1 << " instead of " << ans2 << endl;
			cout << n << endl;
			for (int i = 0; i < n; i++) cout << a[i] << " \n"[i + 1 == n];
			break;
		}
	}
	exit(0);
}

int main() {
	stress(0);
	freopen("subsequences.in", "r", stdin);
	freopen("subsequences.out", "w", stdout);

	cin >> n;
	a.resize(n);
	for (int i = 0; i < n; i++) cin >> a[i];
	cout << fastsolve() << endl;

	return 0;
}