I wrote a code for a similar problem that is quite precise and can be implemented with ease. Here I take an input n which prints the sum of product for consecutive integers starting from 1, i.e. array size n. In your case, what can be done is that you take the length and array both as the input and run the loop 'array length' times and the loop instead of running for n should read the elements of the array, store them then store their square, increment the address by 4 to read each index and keep adding the squares to the previously updated sum. Your code however is pretty much accurate and seems to give an accurate result.
SUM OF SQUARES
.data #initilisation prompt to ask the user for their input n: .asciiz "enter n: "
.text .globl main main: #declaring i and initiating its value to 0 li $t0, 0
#printing prompt to ask from user li $v0,4 la $a0, n syscall
#inputing value from console li $v0,5 syscall #moving to temporary variable t1 move $t1, $v0
#initialising sum as 0, stored as t3 li $t3 0 #Function acting as a loop function: #condition to end the loop and jump to print function #while(t0!=t1) beq $t0 $t1 print #incrementation of loop variable (t0) addi $t0 $t0 1 #calculating square of t0 and storing it in t4 mul $t4 $t0 $t0 #adding the current squared to previous sum and again storing it in sum(t3) add $t3 $t3 $t4 #loop to this function again j function
#procedure to print the sum(t3) print: move $a0 $t3 li $v0 1 syscall
#exit procedure end: li $v0 10 syscall