import java.util.Arrays;
import java.util.Random;


public class seqStress {
	public static void main(String[] args) {
		Random rnd = new Random(239);
		while (true) {
			int n = 1000;
			int h = rnd.nextInt(170)+4;
			int[] a = new int[n];
			for (int i = 0; i < n; i++) {
				a[i] = rnd.nextInt(10);			
			}
			long ans1 = new seq_vd().solve(a, n, h);
			long ans2 = new seq_vd_slow().solve(a, n, h);
			System.err.println(ans1 +" "+ans2);
			if (ans1 != ans2) {
				System.err.println(n+" "+h);
				System.err.println(Arrays.toString(a));
				
				throw new AssertionError();
			}
		}
	}
}
