EditorialSet Ai=2i−1A_i=2i-1Ai=2i−1. These values are distinct and lie between 111 and 2N2N2N. A contiguous subsequence of length kkk starting with 2l−12l-12l−1 has sum k(2l+k−2)k(2l+k-2)k(2l+k−2), so its average is always an integer. The time complexity is O(N)O(N)O(N). Solution written by GPT5