Problem declaring and using an array

I haven't used the IDE for a while, and I can't see what's wrong with this:

float sensors[3];
sensors[0]=123.0;


void setup() {
  // put your setup code here, to run once:

}

void loop() {
  // put your main code here, to run repeatedly:

}

Error message:

Compiling sketch...
"C:\Users\johnd\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\7.3.0-atmel3.6.1-arduino5/bin/avr-g++" -c -g -Os -Wall -Wextra -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -MMD -flto -mmcu=atmega4809 -DF_CPU=16000000L -DARDUINO=10607 -DARDUINO_AVR_NANO_EVERY -DARDUINO_ARCH_MEGAAVR -DAVR_NANO_4809_328MODE -DMILLIS_USE_TIMERB3 -DNO_EXTERNAL_I2C_PULLUP "-IC:\Users\johnd\AppData\Local\Arduino15\packages\arduino\hardware\megaavr\1.8.8\cores\arduino/api/deprecated" "-IC:\Users\johnd\AppData\Local\Arduino15\packages\arduino\hardware\megaavr\1.8.8\cores\arduino" "-IC:\Users\johnd\AppData\Local\Arduino15\packages\arduino\hardware\megaavr\1.8.8\variants\nona4809" "C:\Users\johnd\AppData\Local\arduino\sketches\ACD0D25056E2AE4EB76029B1129F81AD\sketch\sketch_apr4a.ino.cpp" -o "C:\Users\johnd\AppData\Local\arduino\sketches\ACD0D25056E2AE4EB76029B1129F81AD\sketch\sketch_apr4a.ino.cpp.o"
C:\Users\johnd\AppData\Local\Temp.arduinoIDE-unsaved202534-46904-1m571l9.8u2e\sketch_apr4a\sketch_apr4a.ino:3:1: error: 'sensors' does not name a type
sensors[0]=123.0;
^~~~~~~
exit status 1

Compilation error: 'sensors' does not name a type

this is outside a function. could put in in setup() or do this instead

float sensors[3] = { 123.0 };

D'oh! Thanks!