Firstly you are hanging the system by calling Serial in an ISR:
void timerIsr()
{
x=analogRead(A0);
var[n]=x;
n=n+1;
Serial.println(n); // MUST NOT CALL Serial methods in an ISR!!!!!!!
if(n==50) {
interrupts(); // pointless, interrupts are re-enabled on exiting an ISR
}
}
secondly you confuse == with = here:
for (i ==1;i<51;i++)
Thirdly variables shared between an ISR and the rest of the code must
be declared volatile, and if more than a single byte in size have to be
accessed within "noInterrupts() ; ... ; interrupts () ;" from the main
body of the program to avoid mangling.