#include #include #include #include #include using namespace std; int n, ans[1300], x[1301]; bool ok; int main() { cin >> n; ans[0] = 1; for (int i = 1; i <= n; ++i) { cin >> x[i]; if (x[i] < x[i - 1]) ok = true; ans[i] = (ans[i - 1] * 2) % 1000000007; } if (ok) cout << 1; else cout << ans[n - 1]; return 0; }