import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;

enum int modulo = 1_000_000_007;

void main() {
  int n;
  readf (" %d", &n);
  auto c = uninitializedArray!(int[]) (n);
  foreach (i; 0 .. n) {
    readf (" %d", &c[i]);
  }

  int m = 0;
  foreach (i; 1 .. n) {
    if (c[i] != c[m]) {
      c[++m] = c[i];
    }
  }
  n = m + 1;
  debug stderr.writeln (c[0 .. n]);

  m = c.reduce!"max(a,b)";
  auto pos = uninitializedArray!(int[]) (m+1);
  pos[] = -1;
  auto next = new int[n];
  foreach_reverse (i; 0 .. n) {
    next[i] = pos[c[i]];
    pos[c[i]] = i;
  }
  debug stderr.writeln (next);
  auto d = uninitializedArray!(int[]) (n+1);
  d[n] = 1;
  foreach_reverse (i; 0 .. n) {
    d[i] = d[i+1];
    if (next[i] >= 0) {
      debug stderr.writefln ("i = %d, next[i] = %d", i, next[i]);
      d[i] += d[next[i]];
      if (d[i] >= modulo) d[i] -= modulo;
    }
  }
  debug stderr.writeln (d);
  writeln (d[0]);
}

