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

#define mod 1000000007
#define maxn 200005
int c[maxn], pre[maxn], dp[maxn];

int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) scanf("%d", c + i);
  n = unique(c, c + n + 1) - c;
  dp[1] = 1;
  pre[c[1]] = 1;
  for (int i = 2; i < n; i++) {
    dp[i] = (dp[i - 1] + dp[pre[c[i]]]) % mod;
    pre[c[i]] = i;
  }
  cout << dp[n - 1] << endl;
  return 0;
}
