Apologies for the simple question, but I’m having trouble understanding how vectorization works in Stan.

The following code with a for loop works correctly

```
for (n in 1:N) {
target += log(lognormal_cdf(y_upper[n] | mu, sigma) - lognormal_cdf(y_lower[n] | mu, sigma));
}
```

while the “vectorized” code I thought was equivalent does not:

```
target += log(lognormal_cdf(y_upper | mu, sigma) - lognormal_cdf(y_lower | mu, sigma));
```

Could someone explain how to correctly vectorize the for loop?

## Full code

```
data {
int<lower=0> N;
array[N] int y_lower;
array[N] int y_upper;
}
parameters {
real mu;
real<lower=0> sigma;
}
model {
for (n in 1:N) {
target += log(lognormal_cdf(y_upper[n] | mu, sigma) - lognormal_cdf(y_lower[n] | mu, sigma));
}
}
```