#include using namespace std; int main(){ int n; cin >> n; vector m(n); for(int m_i = 0; m_i < n; m_i++){ cin >> m[m_i]; } unsigned long long num = 0; for(int i = 0; i < n-1; i++){ while(i < n-1 && m[i] > m[i+1]) i++; num++; } cout << (unsigned long long) (pow(2, num) - 1) % (1000000007) << endl; return 0; }