```#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

#define T9          1000000000
#define T18         1000000000000000000LL
#define INF         1011111111
#define LLINF       1000111000111000111LL

#define EPS         (double)1e-10
#define PI          3.14159265358979323846264
#define rank        wahayawehasdakw
// modulo
#define mod %
#define NUM  1000000007
#define NUM1 1000000009
//scanf type macros
#define s(n) scanf("%d", &n)
#define sl(n) scanf("%ld", &n)
#define sl3(n1,n2,n3) scanf("%lld %lld %lld ", &n1, &n2, &n3)
#define sl4(n1,n2,n3,n4) scanf("%ld %ld %ld %ld", &n1, &n2, &n3, &n4)
#define sll(n) scanf("%I64d", &n)
#define sll2(n) scanf("%lld", &n)
//printf type macros
#define p(n) printf("%d\n", n)
#define pl(n) printf("%ld\n",n)
#define pl3(n1,n2,n3) printf("%lld %lld %lld\n ", n1, n2, n3)
#define pl4(n1,n2,n3,n4) printf("%ld %ld %ld %ld\n ", n1, n2, n3, n4)
#define pll(n) printf("%I64d\n",n)
#define pll2(n) printf("%lld\n",n)

//*************************************************************************************
int32_t solve();    // * Iterative Function to calculate (x^y)%p in O(log y) */

int32_t main(int argc, char** argv) {

ios_base::sync_with_stdio(0);cin.tie(0);
#ifdef LOCAL
//   FREIN("input.txt");
//   FREOUT("out.txt");
#endif
return solve();
}
//red blue ok but i hate palindromes
int32_t solve(){
ll n;sll2(n);ll  A[1000000]; ll k=0,count1=0,count2=0,i,j;
for (i = 1,j=n; i+2 != j && i<=j; i++,j--) {

if(n%2==0){//100% ok

if(i%2==0&&i+1==j){
if(count2==count1)//extra condition
{
count1+=i,A[k++]=i,count2+=j;
}

else {count2+=i+j;}
}
else if(i%2==0&&i+1!=j){count2+=i+j;}

//coding is love and fun
else if(i%2!=0&&i+1==j){
if(count2==count1)
{A[k++]=i,count1+=i,count2+=j;}
else {count2+=i+j;}//extra condition
}

else if(i%2!=0&&i+1!=j){A[k++]=i,A[k++]=j,count1+=i+j;}
}
else {//for odd case
//for odd lenght both cases for even psotion and odd position
if(i%2!=0){A[k++]=i,A[k++]=j,count1+=i+j;}
else {count2+=i+j;}

}

}

ll a=0,b=0,c=0,ans=0;
if(n%2!=0){
if(count2!=count1){//worng problem here
a=(abs((count2+j+i+1)-(count1+i)));
b=(abs((count2+i+j)-(count1+i+1))),c=(abs((count2+i+i+1)-(count1+j)));
ans=min(min(a,min(b,c)),min(b,min(a,c)));
if(ans==a){
count2=count2+j+i+1,count1+=i,A[k++]=i;}
else if(ans==b){
count2=count2+j+i,count1+=i+1,A[k++]=i+1;}
else if(ans==c){ count2=count2+i+i+1,count1+=j,A[k++]=j;}

}

else {
A[k++]=i,A[k++]=i+1,count1=count1+i+(i+1),count2+=j;

}
}
std::cout << abs(count1-count2) <<"\n";
std::cout << k <<" ";

for (i = 0; i < k; i++) {
/* code */
cout<<A[i]<<" ";
}

return 0;}
```

### Output:

```Output has been truncated..please click on RUN to regenrate complete output when required.

29994
29996 1 59991 3 59989 5 59987 7 59985 9 59983 11 59981 13 59979 15 59977 17 59975 19 59973 21 59971 23 59969 25 59967 27 59965 29 59963 31 59961 33 59959 35 59957 37 59955 39 59953 41 59951 43 59949 45 59947 47 59945 49 59943 51 59941 53 59939 55 59937 57 59935 59 59933 61 59931 63 59929 65 59927 67 59925 69 59923 71 59921 73 59919 75 59917 77 59915 79 59913 81 59911 83 59909 85 59907 87 59905 89 59903 91 59901 93 59899 95 59897 97 59895 99 59893 101 59891 103 59889 105 59887 107 59885 109 59883 111 59881 113 59879 115 59877 117 59875 119 59873 121 59871 123 59869 125 59867 127 59865 129 59863 131 59861 133 59859 135 59857 137 59855 139 59853 141 59851 143 59849 145 59847 147 59845 149 59843 151 59841 153 59839 155 59837 157 59835 159 59833 161 59831 163 59829 165 59827 167 59825 169 59823 171 59821 173 59819 175 59817 177 59815 179 59813 181 59811 183 59809 185 59807 187 59805 189 59803 191 59801 193 59799 195 59797 197 59795 199 59793 201 59791 203 59789 205 59787 207 59785 209 59783 211 59781 213 59779 215 59777 217 59775 219 59773 221 59771 223 59769 225 59767 227 59765 229 59763 231 59761 233 59759 235 59757 237 59755 239 59753 241 59751 243 59749 245 59747 247 59745 249 59743 251 59741 253 59739 255 59737 257 59735 259 59733 261 59731 263 59729 265 59727 267 59725 269 59723 271 59721 273 59719 275 59717 277 59715 279 59713 281 59711 283 59709 285 59707 287 59705 289 59703 291 59701 293 59699 295 59697 297 59695 299 59693 301 59691 303 59689 305 59687 307 59685 309 59683 311 59681 313 59679 315 59677 317 59675 319 59673 321 59671 323 59669 325 59667 327 59665 329 59663 331 59661 333 59659 335 59657 337 59655 339 59653 341 59651 343 59649 345 59647 347 59645 349 59643 351 59641 353 59639 355 59637 357 59635 359 59633 361 59631 363 59629 365 59627 367 59625 369 59623 371 59621 373 59619 375 59617 377 59615 379 59613 381 59611 383 59609 385 59607 387 59605 389 59603 391 59601 393 59599 395 59597 397 59595 399 59593 401 59591 403 59589 405 59587 407 59585 409```