#include<iostream> #include<cstring> #include<cmath> #include<cstdio> #include<algorithm> using namespace std; const int inf = 0x7f7f7f; const int mod = 1e9 + 7; typedef long long ll; ll a[1010]; ll qpow(ll b, ll c) { ll ans = 1; while(c) { if(c & 1) ans =...