title: Find Repetitive Element 1 N 1
signature: find_repetitive_element_1_n_1 <- function(arr, n) {
test_code: 
  
  
  # SOLUTION CODE
  # ============================================
  PLACEHOLDER_CODE_BODY
  
  # TESTING CODE 
  # ============================================
  validate_solution <- function(actual, expected) {
      toString(actual)==toString(expected)
  }
  
  driver <- function(arr, n, expected){
      if (validate_solution(PLACEHOLDER_FN_NAME(arr, n), expected)){
          "PASSED"
      } else{
          "FAILED"
      }
  }
  
  main <- function() {
      cat(sprintf("TEST-0...%s\n",driver(
          list(4L, 8L, 27L, 34L, 39L, 42L, 43L, 54L, 72L), 5L, 
          313L
      )))
  
      cat(sprintf("TEST-1...%s\n",driver(
          list(-38L, -66L, -38L, -48L, -96L, 74L, -32L, -62L, -34L, -32L, -88L, -12L, -8L, -4L), 9L, 
          -520L
      )))
  
      cat(sprintf("TEST-2...%s\n",driver(
          list(0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 1L, 1L, 1L, 1L), 8L, 
          -23L
      )))
  
      cat(sprintf("TEST-3...%s\n",driver(
          list(88L, 86L, 23L, 81L, 76L, 16L, 94L, 64L, 59L, 50L, 71L, 62L, 10L, 89L, 73L, 64L, 65L, 96L, 83L, 40L, 99L, 40L, 77L, 33L, 14L, 62L, 6L, 89L, 74L, 96L, 93L, 29L, 15L, 93L, 9L, 58L, 98L, 76L, 23L, 23L, 70L, 99L), 31L, 
          2101L
      )))
  
      cat(sprintf("TEST-4...%s\n",driver(
          list(-96L, -94L, -82L, -64L, -56L, -40L, -36L, -34L, -32L, -24L, -24L, -22L, -20L, -20L, -20L, -18L, -18L, -12L, -10L, -6L, 16L, 20L, 20L, 22L, 26L, 30L, 36L, 46L, 46L, 50L, 50L, 52L, 64L, 64L, 64L, 68L, 72L, 74L, 76L, 92L, 96L, 98L), 28L, 
          76L
      )))
  
      cat(sprintf("TEST-5...%s\n",driver(
          list(0L, 1L, 1L, 1L, 1L, 0L, 0L, 0L, 1L, 1L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 0L, 0L, 1L, 0L, 0L, 1L, 1L, 0L, 1L, 1L), 25L, 
          -288L
      )))
  
      cat(sprintf("TEST-6...%s\n",driver(
          list(2L, 6L, 7L, 13L, 19L, 23L, 37L, 39L, 42L, 42L, 43L, 45L, 52L, 53L, 55L, 56L, 59L, 63L, 66L, 71L, 76L, 85L, 86L, 89L, 92L, 94L, 96L, 99L), 27L, 
          1159L
      )))
  
      cat(sprintf("TEST-7...%s\n",driver(
          list(52L, -56L, -12L, 78L, 6L, 32L, 0L, 36L, 34L, -54L, -74L, -32L), 11L, 
          -45L
      )))
  
      cat(sprintf("TEST-8...%s\n",driver(
          list(0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L), 15L, 
          -86L
      )))
  
      cat(sprintf("TEST-9...%s\n",driver(
          list(10L, 42L, 50L, 5L, 74L, 81L, 30L, 76L, 6L, 34L, 86L, 4L, 77L, 71L, 96L, 22L, 34L, 50L, 35L, 16L, 60L, 11L, 21L, 38L), 13L, 
          951L
      )))
  
  }
  
  main()
source_py: def find_repetitive_element_1_n_1(arr, n):
      return (sum(arr) - (((n - 1) * n) // 2))
source_cpp: int find_repetitive_element_1_n_1(vector<int> arr, int n) {
    return accumulate(arr.begin(), arr.end(), 0 ) - ( ( n - 1 ) * n / 2 );
  }