#include <iostream>
#define int long long
using namespace std;
const int P = 1000000007;
inline void Madd(int& x, int y) { (x += y) >= P ? (x -= P) : 0; }
int n;
int dp[2][80][80][80];
int pw[1005];
int x[1005];
signed main() {
cin >> n;
for (int i = 1; i <= n; i++) cin >> x[i];
pw[0] = 1;
for (int i = 1; i <= n; i++) pw[i] = pw[i - 1] * 2 % P;
dp[0][0][0][0] = 1;
int ans = 0;
for (int i = 1; i <= n; i++) {
int d = x[i] - x[i - 1];
memset(dp[1], 0, sizeof dp[1]);
for (int a = 0; a <= 75; a++) {
for (int b = 0; b <= 75; b++) {
for (int c = 0; c <= 75; c++) {
if (!dp[0][a][b][c])
continue;
static int f[6];
f[0] = max(0ll, a - d), f[1] = max(0ll, b - d), f[2] = max(0ll, c - d);
for (int i = 0; i < 5; i++) {
f[i + 1] = max(f[i + 1], f[i] + 20);
if (i + 3 < 6)
f[i + 3] = max(f[i + 3], f[i] + 75);
}
Madd(dp[1][f[0]][f[1]][f[2]], dp[0][a][b][c]);
int j = 0;
while (!f[j]) ++j;
Madd(ans, j * dp[0][a][b][c] % P * pw[n - i] % P);
Madd(dp[1][f[j]][f[j + 1]][f[j + 2]], dp[0][a][b][c]);
}
}
}
}
cout << (ans << 1) % P << "\n";
return 0;
}