I used the for loop code found on the internet but my professor asked me to convert it to while loop. I also don't have any idea how to code the sum part. We can't use any advanced stuff like def. I only started to code for class using python and I've honestly been stuck and haven't been catching up on the lessons. Any help is appreciated, thank you.
import array as arr
a=arr.array('i', [])
x=0
#size of array
arrsize=int(input("\nPlease Enter the number of elements: "))
#elements
print("\nPlease Enter "+str(arrsize)+" elements")
while(x<arrsize):
num=int(input("Enter a number: "))
a.insert(x,num)
x+=1
print("The elements are: ",a)
#duplicate elements
for i in range (0, len(a)):
for j in range (i+1, len(a)):
if(a[i]==a[j]):
print("\nThe duplicate elements are: ",(a[j]))