#include #include using namespace std; const int INF = 1<<30; // 2 ^ 30 const int MAXN = 100*1000; int a[MAXN+10]; int d[MAXN+10]; int last[MAXN+10]; int main(){ ios::sync_with_stdio(false); int n; cin >> n; for(int i=0; i> a[i]; for(int i=0; i