def find_pattern(cs, count)
  unless cs.uniq.size == cs.size
    len = cs.size
    (0..len - 1).each do |i|
      (i + 2..len - 1).each do |j|
        next if cs[i] != cs[j] || cs[j - 1] == cs[j]

        count += 1
        count = find_pattern(cs[j + 1..-1], count)
      end
    end
  end
  count
end

n = gets.to_i
cs = n.times.map do
  gets.to_i
end

count = 1
count = find_pattern(cs, count)
puts count
