M=10**9+7

def div_conq(l,r,c)
  return 1 if r-l<=1
  if r-l==2
    return c[l]==c[r] ? 2 : 1
  end
  m=(l+r)/2
  l_num=div_conq(l,m,c)
  r_num=div_conq(m+1,r,c)
  sum=l_num*r_num
  l_h=Hash.new(0)
  r_h=Hash.new(0)
  ret=0
  m.downto(l){|k|l_h[c[k]]+=1}
  (m+1).upto(r){|k|r_h[c[k]]+=1}
  l_h.each{|key,val|ret+=val*r_h[key]}
  #p [l,r,(ret+sum)%M,ret,l_num,r_num]
  (ret+sum)%M
end

n=gets.to_i
d=n.times.map{gets.to_i}
c=[]
prev=-1
d.each{|val|
  c << val if prev!=val
  prev=val
}
puts div_conq(0,c.size-1,c)