#!/bin/python import sys n = int(raw_input().strip()) m = map(int, raw_input().strip().split(' ')) # your code goes here count = 0 for i in range(1,n): if m[i] >= m[i-1]: count += 1 pass else: break pass ac = 1 for i in range(0,count): ac *= 2 ac %=10e9+7 pass print int(ac)