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

using namespace std;

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

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

int calcdp(vector<int> a) {
    int n = a.size();
    vector<int> dp(n + 1);
    dp[0] = 1;
    for (int j = 0; 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;
        mp[a[j]] = j;
    }   
    for (int j = 0; j < n; j++) mp[a[j]] = -1;
    return dp[n];
}

int slowsolve() {
    memset(mp, -1, sizeof(mp));
    int ans = 0;
    for (int i = 0; i < n; i++) {
        vector<int> b;
        for (int j = i; j < n; j++) {
            b.push_back(a[j]);
            ans = (ans + calcdp(b)) % mod;
        }
    }
    return ans;
}

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

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

    return 0;
}