user
Below is an instruction that describes a task, paired with an input that provides further context. Write a response that appropriately completes the request.

### Instruction:
Edit the given code to optimize its performance.

### Input:
for i in range(N):
    for j in range(N-1):
        sum += A[i][j]

### Response:
assistant
sum = 0
for j in range(N-1):
    for i in range(N):
        sum += A[i][j]