unittest
{
	assert( [ "5", "1", "2", "1", "2", "2" ].parse.expand.solve == 3 );
	assert( [ "6", "4", "2", "5", "4", "2", "4" ].parse.expand.solve == 5 );
	assert( [ "7", "1", "3", "1", "2", "3", "3", "2" ].parse.expand.solve == 5 );
}



import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto n = input.front.to!( long );
	auto cs = new long[ n ];
	foreach( ref c; cs )
	{
		input.popFront;
		c = input.front.to!( long );
	}
	return tuple( cs );
}

auto solve( long[] cs )
{
	long[ long ] pps;
	auto pc = 0L;
	auto pp = 0L;
	auto ans = 1L;
	foreach( c; cs )
	{
		if( pc == c ) continue;
		pc = c;
		pp = ans;
		
		if( c in pps )
		{
			ans = addMod( ans, pps[ c ] );
			pps[ c ] = addMod( pps[ c ], pp );
		}
		else
		{
			pps[ c ] = pp;
		}
	}
	return ans;
}

// 足し算
auto addMod( long MOD = 10L ^^ 9 + 7 )( long x, long y )
{
	return ( x + y ) % MOD;
}
