#include<stdio.h>
int main(void){
  char *s="python3 -c\""
"n,*c=map(int,open(0).readlines())\n"
"l=[-1]*2**18\n"
"b=[]\n"
"for i in range(n):\n"
"  b.append(l[c[i]])\n"
"  l[c[i]]=i\n"
"dp=[1]+[0]*n\n"
"for i in range(1,n):\n"
"  dp[i]=dp[i-1]\n"
"  if c[i]!=c[i-1]and b[i]>-1:\n"
"    dp[i]=(dp[i]+dp[b[i]])%(10**9+7)\n"
"print(dp[-2])\n"
"\"";
  system(s);
  return 0;
}            