include "stdafx.h"
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<math.h>
#include<iomanip>
#include<numeric>
#include<list>
#include<deque>
#include<queue>
using namespace std;
int main()
{
int n;
while (cin>>n)
{
vector <int> numVec; //存储气球的个数
vector <int> colors; //存储颜色
int num;
cin >> num;
colors.push_back(num);
numVec.push_back(1);//当有零个气球时
numVec.push_back(1);//当有一个气球时
for (int i = 1;i < n;i++)
{
int num;
cin >> num;
int cp = colors.size()-1;
int np = numVec.size()-1;
long long p = numVec[np];
// cout << "概率:" << p << endl;
for (int j = colors.size()- 1;j >= 0;j--)
{
if (colors[j] != num)
{
bool flag = true;
for (int k = j+1;k < colors.size();k++)//前面有任何一个气球和j相等则不能把气球j和后面的气球分成一组
{
if (colors[k] == colors[j])
{
flag = false;
}
}
if (flag == true)
{
p += numVec[np - cp + j - 1];
}
else
{
break;
}
}
else
{
break;
}
}
numVec.push_back(p%1000000007);//不要忘了取余数!!!!!!
// cout << "概率:" << p << endl;
colors.push_back(num);
}
cout << numVec[numVec.size() - 1] << endl;
}
return 0;
}