n=gets.chomp.to_i
c_ary = []
c_hash={}
n.times{|_| c_ary << gets.chomp.to_i}
b_i = 0
c_ary.uniq.each do |c|
  c_hash[c] = []
end
c_ary.each_with_index do |c, idx|
  break if idx + 1 > c.size
  c_hash[c] << idx if c != c_ary[idx+1]
end

c_hash_ary = []
c_hash.values.each do |v|
  next if v.size < 2
  c_hash_ary = c_hash_ary + v.combination(2).to_a
end
c_head = c_hash_ary.map{|c| c[0]}
c_last = c_hash_ary.map{|c| c[1]}
count = 1
last_s = c_last.size
last_s_i = c_last.size - 1
c_last.each_with_index do |c, idx|
  i = idx + 1
  cnt = 0
  if i != last_s
    i.upto(last_s_i) do |j|
      cnt += 1 if c_head[j] > c
    end
  end
  count += 2**cnt
end

p count