long[] (@ExpectNotNull long[] arr, int from, int to) { int diff = to - from; if (diff < 0) { throw new IllegalArgumentException("Invalid arguments: " + from + '>' + to); } long[] copy = new long[diff]; System.arraycopy(arr, from, copy, 0, Math.min(arr.length - from, diff)); return copy; }