Sum of array elements divisible by 3
PHP
Easy
arrays
Task «Sum of array elements divisible by 3»
Write a program that reads an array of integers and calculates the sum of all elements that are divisible by 3 without a remainder. If there are no such elements, output 0.
Input Format
The first line contains an integer N (1 ≤ N ≤ 100) — the number of elements in the array. The second line contains N integers separated by spaces.
Output Format
One integer — the sum of elements that are multiples of 3.
Examples
Example 1
INPUT
3
9 12 15
OUTPUT
36
Example 2
INPUT
5
1 2 3 4 5
OUTPUT
3
main.php