#include <iostream>
#include <cstdio>
#include <vector>
#include <map>
#include <cstdlib>
#include <memory.h>
#include <cassert>

using namespace std;

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

int n;
vector<int> a;
int mp[maxn];

int slowsolve() {
	int ans = 0;
	memset(mp, -1, sizeof(mp));

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

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

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

	return 0;
}