Company: Deloitte_5_feb
Difficulty: medium
Sum of Every Xth Element Description You are given a list of integers, arr , with N elements, and a number X which specifies an interval. Your task is to write a program that calculates the sum of every X th element in arr , starting from the first element. Note: Based on the sample case, the problem requires summing elements at 1-based positions X, 2X, 3X, ... . In a 0-indexed array, this corresponds to indices X-1, 2X-1, 3X-1, ... . Input Format The first line of input contains an integer N , the size of the list arr . The second line contains N space-separated integers, the elements of arr . The third line contains an integer X , which denotes the interval. Output Format The first line of output contains the sum of every X th number in the given list arr . Constraints 1 < N <= 1000 1 <= list elements <= 10000 X < N Example 1 Input 4 1 2 3 4 2 Output 6 Explanation Given N = 4 , the array arr is [1, 2, 3, 4] . The interval X is 2 . We need to sum every 2 nd element. Thi