---
# System prepended metadata

title: 2535. Difference Between Element Sum and Digit Sum of an Array
tags: [Leetcode, Easy]

---

# 2535. Difference Between Element Sum and Digit Sum of an Array
###### tags: `Leetcode` `Easy`
Link: https://leetcode.com/problems/difference-between-element-sum-and-digit-sum-of-an-array/description/
## Code
```python=
class Solution:
    def differenceOfSum(self, nums: List[int]) -> int:
        elementSum = sum(nums)
        digitSum = 0
        for num in nums:
            while num>0:
                digitSum += num%10
                num //= 10
        return abs(digitSum-elementSum)
```