Language: C++

 //minamoto
#include<bits/stdc++.h>
#define R register
#define ll long long
#define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(R int i=(a),I=(b)-1;i>I;--i)
#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
using namespace std;
char buf[1<<21],*p1=buf,*p2=buf;
inline char getc(){return p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++;}
int read(){
    R int res,f=1;R char ch;
    while((ch=getc())>'9'||ch<'0')(ch=='-')&&(f=-1);
    for(res=ch-'0';(ch=getc())>='0'&&ch<='9';res=res*10+ch-'0');
    return res*f;
}
const int N=2e5+5,P=1e9+7;
inline int add(R int x,R int y){return x+y>=P?x+y-P:x+y;}
inline int mul(R int x,R int y){return 1ll*x*y-1ll*x*y/P*P;}
int c[N],sum[N],g[N],n,res,tot;
int main(){
//	freopen("testdata.in","r",stdin);
	n=read();
	fp(i,1,n)c[i]=read();
	for(R int i=1;i<=n;++i)(c[i]!=c[i-1])?c[++tot]=c[i]:0;
	g[0]=1;
	fp(i,1,tot){
		g[i]=add(sum[c[i]],g[i-1]),
		sum[c[i]]=add(sum[c[i]],g[i-1]),
	}
	printf("%d\n",g[tot]);
	return 0;
}

Compiler output:
a.cc: In function 'int read()':
a.cc:12:11: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   12 |     R int res,f=1;R char ch;
      |           ^~~
a.cc:12:15: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   12 |     R int res,f=1;R char ch;
      |               ^
a.cc:12:26: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   12 |     R int res,f=1;R char ch;
      |                          ^~
a.cc: At global scope:
a.cc:18:22: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   18 | inline int add(R int x,R int y){return x+y>=P?x+y-P:x+y;}
      |                      ^
a.cc:18:30: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   18 | inline int add(R int x,R int y){return x+y>=P?x+y-P:x+y;}
      |                              ^
a.cc:19:22: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   19 | inline int mul(R int x,R int y){return 1ll*x*y-1ll*x*y/P*P;}
      |                      ^
a.cc:19:30: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   19 | inline int mul(R int x,R int y){return 1ll*x*y-1ll*x*y/P*P;}
      |                              ^
a.cc: In function 'int main()':
a.cc:24:12: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   24 |         fp(i,1,n)c[i]=read();
      |            ^
a.cc:5:29: note: in definition of macro 'fp'
    5 | #define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
      |                             ^
a.cc:5:35: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
    5 | #define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
      |                                   ^
a.cc:24:9: note: in expansion of macro 'fp'
   24 |         fp(i,1,n)c[i]=read();
      |         ^~
a.cc:25:19: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   25 |         for(R int i=1;i<=n;++i)(c[i]!=c[i-1])?c[++tot]=c[i]:0;
      |                   ^
a.cc:27:12: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   27 |         fp(i,1,tot){
      |            ^
a.cc:5:29: note: in definition of macro 'fp'
    5 | #define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
      |                             ^
a.cc:5:35: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
    5 | #define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
      |                                   ^
a.cc:27:9: note: in expansion of macro 'fp'
   27 |         fp(i,1,tot){
      |         ^~
a.cc:30:9: error: expected primary-expression before '}' token
   30 |         }
      |         ^