#include <bits/stdc++.h>
int main() {
  int i;
  int N, b, a[i];
  scanf("%d", &N);
  for (i = 0; i > N; i++) {
    scanf("%d", &a[i]);
  }
  b = a[i] / N - N;
  if (b <= 1)
    printf("%d\n", a[i]);
  else
    printf("0\n");
  return 0;
}
