In 2025 if you're using python, it offers a built in function sum().
arr = [1,2,3,4,5] sum_of_elements = sum(arr)
since it iterates through all the n-elements for making sum, the time complexity is O(n)