#include <bits/stdc++.h>
using namespace std;

const int MN = 2e5+5, mod = 1e9+7;
int dp[MN], lst[MN], N, i, x, y;

int main(){
    for(scanf("%d",&N),i=1;i<=N;i++){
        scanf("%d",&x);
        dp[i] = dp[i-1];
        if(lst[x]&&x!=y) dp[i]=(dp[i]+dp[lst[x]]+1)%mod;
        lst[x]=i; y=x;
    }
    printf("%d\n",(dp[N]+1)%mod);
    return 0;
}
