#include <cstdio>
#include <iostream>
#include <vector>
using namespace std;

const int INF = (int)1e9 + 7;

int main()
{
    freopen("lesson.in", "r", stdin);
    freopen("lesson.out", "w", stdout);
    int n;
    scanf("%d", &n);
    if (n == 1)
    {
        cout << 1 << endl;
        return 0;
    }
    vector<int> a(n + 1);
    for (int i = 1; i <= n; i++)
        scanf("%d", &a[i]);
    if (a[1] > a[2])
        a[0] = INF;
    else
        a[0] = -INF;
    vector<int> b(n + 1);
    for (int i = 0; i < n; i++)
        b[i] = a[i + 1] - a[i];
    vector<int> dp(n + 1);
    dp[0] = 1;
    for (int i = 1; i <= n; i++)
    {
        dp[i] = 0;
        bool is_inc = true;
        bool is_dec = true;
        for (int j = i - 1; j >= 0 && (is_inc || is_dec); j--)
        {
            if (b[j] < 0)
                is_inc = false;
            else if (b[j] > 0)
                is_dec = false;
            dp[i] = (dp[i] + dp[j]) % INF;
        }
    }
    //for (int i = 1; i <= n; i++)
    //    cout << dp[i] << ' ';
    cout << dp[n] << endl;
    return 0;
}