#include <bits/stdc++.h>
// #include <windows.h>
// #include <bits/extc++.h>
// using namespace __gnu_pbds;
using namespace std;
//#pragma GCC optimize(3)
#define DB double
#define LL long long
#define ULL unsigned long long
#define in128 __int128
#define cint const int
#define cLL const LL
#define For(z,e1,e2) for(int z=(e1);z<=(e2);z++)
#define Rof(z,e1,e2) for(int z=(e2);z>=(e1);z--)
#define For_(z,e1,e2) for(int z=(e1);z<(e2);z++)
#define Rof_(z,e1,e2) for(int z=(e2);z>(e1);z--)
#define inint(e) scanf("%d",&e)
#define inll(e) scanf("%lld",&e)
#define inpr(e1,e2) scanf("%d%d",&e1,&e2)
#define in3(e1,e2,e3) scanf("%d%d%d",&e1,&e2,&e3)
#define outint(e) printf("%d\n",e)
#define outint_(e) printf("%d%c",e," \n"[i==n])
#define outint2_(e,e1,e2) printf("%d%c",e," \n"[(e1)==(e2)])
#define outll(e) printf("%lld\n",e)
#define outll_(e) printf("%lld%c",e," \n"[i==n])
#define outll2_(e,e1,e2) printf("%lld%c",e," \n"[(e1)==(e2)])
#define exc(e) if(e) continue
#define stop(e) if(e) break
#define ret(e) if(e) return
#define ll(e) (1ll*(e))
#define pb push_back
#define ft first
#define sc second
#define pii pair<int,int>
#define pli pair<LL,int>
#define vct vector
#define clean(e) while(!e.empty()) e.pop()
#define all(ev) ev.begin(),ev.end()
#define sz(ev) ((int)ev.size())
#define debug(x) printf("%s=%d\n",#x,x)
#define x0 __xx00__
#define y1 __yy11__
#define ffo fflush(stdout)
// cLL mod=998244353,G=404;
cLL mod=1000000007ll;
// cLL mod[2]={1686688681ll,1888686661ll},base[2]={166686661ll,188868881ll};
template <typename Type> void get_min(Type &w1,const Type w2) { if(w2<w1) w1=w2; } template <typename Type> void get_max(Type &w1,const Type w2) { if(w2>w1) w1=w2; }
template <typename Type> Type up_div(Type w1,Type w2) { return (w1/w2+(w1%w2?1:0)); }
template <typename Type> Type gcd(Type X_,Type Y_) { Type R_=X_%Y_; while(R_) { X_=Y_; Y_=R_; R_=X_%Y_; } return Y_; } template <typename Type> Type lcm(Type X_,Type Y_) { return (X_/gcd(X_,Y_)*Y_); }
template <typename Type> Type md(Type w1,const Type w2=mod) { w1%=w2; if(w1<0) w1+=w2; return w1; } template <typename Type> Type md_(Type w1,const Type w2=mod) { w1%=w2; if(w1<=0) w1+=w2; return w1; }
void ex_gcd(LL &X_,LL &Y_,LL A_,LL B_) { if(!B_) { X_=1ll; Y_=0ll; return ; } ex_gcd(Y_,X_,B_,A_%B_); X_=md(X_,B_); Y_=(1ll-X_*A_)/B_; } LL inv(LL A_,LL B_=mod) { LL X_=0ll,Y_=0ll; ex_gcd(X_,Y_,A_,B_); return X_; }
template <typename Type> void add(Type &w1,const Type w2,const Type M_=mod) { w1=md(w1+w2,M_); } void mul(LL &w1,cLL w2,cLL M_=mod) { w1=md(w1*md(w2,M_),M_); } template <typename Type> Type pw(Type X_,Type Y_,Type M_=mod) { Type S_=1; while(Y_) { if(Y_&1) mul(S_,X_,M_); Y_>>=1; mul(X_,X_,M_); } return S_; }
template <typename Type> Type bk(vector <Type> &V_) { auto T_=V_.back(); V_.pop_back(); return T_; } template <typename Type> Type tp(stack <Type> &V_) { auto T_=V_.top(); V_.pop(); return T_; } template <typename Type> Type frt(queue <Type> &V_) { auto T_=V_.front(); V_.pop(); return T_; }
template <typename Type> Type bg(set <Type> &V_) { auto T_=*V_.begin(); V_.erase(V_.begin()); return T_; } template <typename Type> Type bk(set <Type> &V_) { auto T_=*prev(V_.end()); V_.erase(*prev(V_.end())); return T_; }
mt19937 gen(time(NULL)); int rd() { return abs((int)gen()); }
int rnd(int l,int r) { return rd()%(r-l+1)+l; }
void main_init()
{
}
cint N=1020,D1=20,D2=75,inf=1.1e9;
int n;
int a[N],nxt[N],nxt2[N];
#define ht gp_hash_table
struct Node
{
LL x,y;
friend Node operator + (Node w1,int w2)
{
w1.y=(w1.y+w1.x*w2)%mod;
return w1;
}
friend void operator += (Node &w1,Node w2)
{
w1.x+=w2.x; if(w1.x>=mod) w1.x-=mod;
w1.y+=w2.y; if(w1.y>=mod) w1.y-=mod;
}
friend void operator -= (Node &w1,Node w2)
{
w1.x-=w2.x; if(w1.x<0ll) w1.x+=mod;
w1.y-=w2.y; if(w1.y<0ll) w1.y+=mod;
}
};
Node dp[N][D2+1][D2+1][D2+1],sum1[N][D2+1][D2+1][D2+1],sum2[N][D2+1][D2+1];
void main_solve()
{
inint(n); For(i,1,n) inint(a[i]);
// n=200; For(i,1,n) a[i]=i;
a[n+1]=inf;
for(int i=1,j=1;i<=n;i++)
{
while(j<n&&a[j+1]-a[i]<D1) j++;
nxt[i]=j;
}
for(int i=1,j=1;i<=n;i++)
{
while(j<n&&a[j+1]-a[i]<D2) j++;
nxt2[i]=j;
}
a[0]=-D2-1;
dp[0][0][0][0]={1ll,0ll};
// int hhh=0;
For(i,0,n)
{
Rof(k3,0,min(D2,i)) For(k2,0,k3)
{
For(k1,0,k2) dp[i][k1][k2][k3]+=sum1[i][k1][k2][k3];
// if(sum2[i][k2][k3].x) printf("%lld,%lld\n",sum2[i][k2][k3].x,sum2[i][k2][k3].y);
dp[i][0][k2][k3]+=sum2[i][k2][k3];
}
Rof(k3,0,min(D2,i)) For(k2,0,k3) For(k1,0,k2)
{
auto w=dp[i][k1][k2][k3];
exc(!(w.x||w.y));
// printf("%d,%d,%d,%d:%lld,%lld\n",i,k1,k2,k3,w.x,w.y);
vct <int> h; h.pb(i),h.pb(nxt[i-k1]),h.pb(nxt2[i-k1]),h.pb(nxt2[i-k2]),h.pb(nxt2[i-k3]),h.pb(n);
sort(all(h)); h.erase(unique(all(h)),h.end());
int len=sz(h);
// printf("[%d,%d]\n",i+1,n);
// int ttt=clock(); //===============================================
int w1=a[i-k1],w2=a[i-k2],w3=a[i-k3];
// printf("> w:%d,%d,%d\n",w1,w2,w3);
For_(j_,0,len-1)
{
int l=h[j_]+1,r=h[j_+1]+1;
exc(r<=i+1);
int t=min(
((a[l]-w1<D1)?-1:0)+1,
((a[l]-w3<D2)?-3:((a[l]-w2<D2)?-2:((a[l]-w1<D2)?-1:0)))+3
);
// printf("> [%d,%d]->t=%d\n",l,r-1,t);
int k1_=(a[l]-w1>=D2?D2:(k1-i)),k2_=(a[l]-w2>=D2?D2:(k2-i)),k3_=(a[l]-w3>=D2?D2:(k3-i));
// printf(" > %d,%d,%d\n",k1_,k2_,k3_);
// For_(j,l,r)
// {
// // printf("%d(%d,%d,%d) %d->%d\n",i,k1,k2,k3,x,x2);
// // assert(x2>=0);
// if(!t) dp[j][k1_][k2_][k3_]+=w;
// else dp[j][j][k1_][k2_]+=(w+t);
// }
if(!t)
{
sum1[l][min(k1_+l,min(D2,l))][min(k2_+l,min(D2,l))][min(k3_+l,min(D2,l))]+=w;
sum1[r][min(k1_+r,min(D2,r))][min(k2_+r,min(D2,r))][min(k3_+r,min(D2,r))]-=w;
}
else
{
sum2[l][min(k1_+l,min(D2,l))][min(k2_+l,min(D2,l))]+=(w+t);
// printf("<> %d,%d,%d %lld,%lld\n",l,min(k1_+l,min(D2,l)),min(k2_+l,min(D2,l)),(w+t).x,(w+t).y);
sum2[r][min(k1_+r,min(D2,r))][min(k2_+r,min(D2,r))]-=(w+t);
}
}
// hhh+=clock()-ttt; //===============================================
/*For(j,i+1,n)
{
int t=min(
((a[j]-a[k1]<D1)?-1:0)+1,
((a[j]-a[k3]<D2)?-3:((a[j]-a[k2]<D2)?-2:((a[j]-a[k1]<D2)?-1:0)))+3
);
// printf("%d(%d,%d,%d) %d->%d\n",i,k1,k2,k3,x,x2);
// assert(x2>=0);
if(!t) dp[j][a[j]-a[k1]>=D2?0:k1][a[j]-a[k2]>=D2?0:k2][a[j]-a[k3]>=D2?0:k3]+=w;
else dp[j][j][a[j]-a[k1]>=D2?0:k1][a[j]-a[k2]>=D2?0:k2]+=(w+t);
}*/
}
Rof(k3,0,min(D2,i)) For(k2,0,k3)
{
For(k1,0,k2) sum1[i+1][min(k1+1,D2)][min(k2+1,D2)][min(k3+1,D2)]+=sum1[i][k1][k2][k3];
sum2[i+1][min(k2+1,D2)][min(k3+1,D2)]+=sum2[i][k2][k3];
}
}
// printf("time=%d\n",hhh);
LL ans=0ll;
For(i,0,n) Rof(k3,0,min(D2,i)) For(k2,0,k3) For(k1,0,k2)
add(ans,dp[i][k1][k2][k3].y);
outll(ans*2ll%mod);
}
int main()
{
// ios::sync_with_stdio(0); cin.tie(0);
// freopen("in.txt","r",stdin);
// freopen("out.txt","w",stdout);
// srand(time(NULL));
main_init();
// int _; inint(_); For(__,1,_) // T>1 ?
// printf("\n------------\n\n"),
main_solve();
return 0;
}
/*
D:\OI\code\untitled3.cpp:113:60: error:
no matching function for call to
'get(__gnu_pbds::gp_hash_table<int, __gnu_pbds::gp_hash_table<int, __gnu_pbds::gp_hash_table<int, Node> > >&, std::tuple_element<0, std::pair<const int, __gnu_pbds::gp_hash_table<int, __gnu_pbds::gp_hash_table<int, Node> > > >::type&, std::tuple_element<0, std::pair<const int, __gnu_pbds::gp_hash_table<int, Node> > >::type&, std::tuple_element<0, std::pair<const int, Node> >::type&)'
sum1[i][k1][k2][k3]+=get(sum1[i-1],k1,k2,k3);
*/