#define _CRT_SECURE_NO_WARNINGS
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 105;
const ll mod = 1e9 + 7;
ll a[N];
ll f(ll l, ll r)
{
    ll max1 = numeric_limits<ll>::min();
    for (ll x = l; x <= r; x++)
        max1 = max(max1, (r - x + 1) * *max_element(a + l, a + x + 1));
    return max1;
}
int main()
{
    int n;
    scanf("%d", &n);
    for (int i = 0; i < n; i++) scanf("%lld", a + i);
    ll ans = 0;
    for (int i = 0; i < n; i++)
        for (int j = i; j < n; j++)
            ans = (ans + f(i, j)) % mod;
    printf("%lld", ans);
    return 0;
}
