#include <cstdio>
#include <iostream>
using namespace std;

int main()
{
	freopen("cave.in", "r", stdin);
	freopen("cave.out", "w", stdout);

      long long n, a[700000], m=0, p=1, p1=0, i1=0;
      cin>>n;
      for (int i=1; i<=n; i++)
          if (i%2!=0) m=m*2+1; else m*=2;  
      for (int i=0; i<n; i++)
      {
          p=1;
          for (int l=0; l<i; l++)
              p*=2;
          p1=p*2;
          i1=(i+1)*(-1);
          for (int j=p; j<=m; j+=p1)
          {
              i1*=(-1);
              a[j]=i1;
          }
      }                               
	cout << m << endl;          
      for (int i=1; i<m; i++)
          printf("%d ", a[i]);
      cout<<a[m]<<endl;           
      return 0;
}
