n = gets.to_i
a = []
n.times do
  a << gets.to_i
end

def count(a, created = {})
  created[a] = true
  a.each_with_index do |e, i|
    s = i + 1
    next if s > a.length - 1
    n = a[s..-1].find_index(e)
    if n && n > 0
      aa = a.dup
      (s..(i + n)).to_a.each do |ii|
        aa[ii] = e
      end
      created[aa] = true
      count(aa, created)
    end
  end
  created.keys.length
end

puts count(a)