function myout(text){console.log(text);}//standard output
function Main(input) {
	//input = parseInt(input);
	//input = input.trim().split(" ");
	//input = input.trim().split("\n");
	//input = input.trim().split(" ").map((a)=>Number(a));
	input = input.trim().split("\n").map((a)=>Number(a));
  var output = 1;//「何もしない」もカウントするため。
  var len = input[0];
  input.shift();
  var list = [];
  var countList = {};
  for(var i = 0; i < len; i++){
    if(list[0] == null){
       list.push(input[i]);
    }else if(list[i - 1] == input[i]){
       continue;
    }else{
      list.push(input[i]);
    }
  }
  for(var i = 0; i < list.length; i++){
    if(countList[list[i]] != null){
       countList[list[i]]++;
    }else{
      countList[list[i]] = 1;
    }
  }
  var countKeys = Object.keys(countList);
  for(var i = 0; i < countKeys.length; i++){
    var tmp = countList[countKeys[i]];
    output = (output + (tmp * (tmp - 1) / 2)) % 1000000007;
  }
  myout(output);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8").trim());
