#include <bits/stdc++.h>
#define INT long long int
using namespace std;
long long int i_S[20][3] = {{2,3,2},{0,1,1},{0,-1,1},{1,-200000000,1},{1,200000000,1},{0,0,1},{15,1231542,15241},{15,-1231542,15241},{5,12542,-141},{5,-12542,141},{0,5,10},{10,1242,11},{10,-12,152},{5,12,-141},{5,-12,141},{2,2,0},{1,2,1},{1,6,9},{4,4,1},{9,6,1}};

char infile[100], outfile[100];

int main() {
    ios::sync_with_stdio(false);
    INT T, I, s, k;
    for(I=1;I<=20;I++){
        sprintf(infile, ".%d.in", I);
        freopen(infile, "w", stdout);
        printf("%lld\n",I-1);

        sprintf(outfile, ".%d.out", I);
        freopen(outfile, "w", stdout);
        if(i_S[I-1][0]==0){
        	if(i_S[I-1][1]>0){
        		s = i_S[I-1][1]*-100000000ll+i_S[I-1][2];
			}else{
				s = i_S[I-1][1]*100000000ll+i_S[I-1][2];
			}
		}else{
			
			k = -1 * (i_S[I-1][1])/(2*i_S[I-1][0]);
			//printf("%lld ",k);
			s = min(i_S[I-1][0]*k*k+i_S[I-1][1]*k+i_S[I-1][2],i_S[I-1][0]*(k+1)*(k+1)+i_S[I-1][1]*(k+1)+i_S[I-1][2]);
			s = min(s,i_S[I-1][0]*(k-1)*(k-1)+i_S[I-1][1]*(k-1)+i_S[I-1][2] );
			
		}
		printf("%lld\n", s);
      }
}
