Problem in code

Hello everyone! I am a beginner in Processing and I have a problem with my code. I have random rectangles but now i want them to be aligned: 4 rows in each 4 rectangles (16 in total). Can someone help?

This is my code for the moment.

int n = 16;
int rectSize = 100;
int[] x = new int[n];
int[] y = new int[n];

void setup() {
size(700, 750);
background(255);
stroke(0);

for(int i=0; i < n; i ++){
x[i] = int(random(width));// Random horizontal position
y[i] = int(random(height));// Random vertical position
}
}

void draw() {
for (int i = 0; i < n; i++) {
// Si la souris est sur le carré i
if (mouseX >= (x[i]-rectSize)
&& mouseX <= (x[i]+rectSize)
&& mouseY >= (y[i]-rectSize)
&& mouseY <= (y[i]+rectSize)) {
stroke(255, 0, 0);
strokeWeight(3);
fill(0);// Red
}
else {
stroke(200);
strokeWeight(3);
fill(0); // White
}
rect(x[i], y[i], rectSize, 150);
}

}

Hello,

There are resources here:

This should help you generate a grid:
https://processing.org/reference/for.html

:)