jiahuimbzuai/CoQuIR huggingface dataset:
//  [java]
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		Integer N = sc.nextInt();
		Integer A, B;
		Integer minSum = 100;

		for (A=1; A<N-1; A++) {
			B = N-A;

			String aStr = A.toString();
			String bStr = B.toString();

			List<String> aDigitList = Arrays.asList(aStr.split(""));
			List<String> bDigitList = Arrays.asList(bStr.split(""));

			int sum=0;

			for(String aDigit : aDigitList) {
				sum += Integer.parseInt(aDigit);
			}

			for(String bDigit : bDigitList) {
				sum += Integer.parseInt(bDigit);
			}

			minSum = Math.min(minSum, sum);
		}

		if(N==2) {
			minSum = 2;
		}


		System.out.println(minSum);
	}
}
//  [cpp]
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
typedef long long ll;

int n;
string t;

int main() {
  cin >> n;
  int ans=0;
  while(n){
    ans+=n%10; n/=10;
  }
  cout << (ans==1?10:ans) << endl;
}
//  [cpp]
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <string.h>
#include <string>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <math.h>
#include <algorithm>
#include <numeric>

using namespace std;

// マクロ&定数 ============================================================
typedef unsigned int uint;
typedef long long ll;
//typedef pair<int, int> P;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<bool> vbool;

typedef vector<vector<int>> vvint;
typedef vector<vector<ll>> vvll;
typedef vector<vector<double>> vvdouble;
typedef vector<vector<bool>> vvbool;

const int INF = 1e9 + 1;
const ll LLINF = 1e17 + 1;
const int DX[9] = { 0,0,1,-1, 1, 1, -1, -1, 0 }; // 4;４近傍
const int DY[9] = { 1,-1,0,0, 1, -1, 1, -1, 0 }; // 8:８近傍 9:(0,0)を含む
const ll MOD = 1e9 + 7; //10^9 + 7
const double PI = 3.14159265358979323846264338327950288;
//========================================================================


int main() {

	//==================================
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(30);
	//==================================

	int N;
	cin >> N;



	int ans = 0;
	for (int i = 0; pow(10, i) <= N; i++) {

		ans += (N % int(pow(10, i+1))) / pow(10, i)  ;


	}

	if (N % 10 == 0 && ans == 1) {
		cout << 10;
		return 0;
	}

	cout << ans;





}
//  [cpp]
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

int main(){ 
  int N; cin >> N;
  int ans = 0;
  
  int test = 1;
  
  for(int i = 0; i < 7; i++){ 
    if( test == N){ cout << 10 << endl; return 0;}
    test *= 10;
  }
  
  while( N > 0){
    ans += N%10;
    N /= 10;
  }
  
  cout << ans << endl; return 0;
}
//  [cpp]
#include <iostream>

using namespace std;

int sumNumericalPositions(int num);

int main(void)
{
	int num;
    int tmp;
	int sum = 0;

	cin >> num;

	for (int i = 1; i <= num / 2; i++) {
		for (int j = num; j >= num / 2; j--) {
			if (i + j == num) {
				tmp = sumNumericalPositions(i) + sumNumericalPositions(j);
				if (sum == 0 || sum > tmp) {
					sum = tmp;
				}
			}
		}
	}

	cout << sum << endl;

	return 0;
}

int sumNumericalPositions(int num)
{
	int sum = 0;
	int tmp;

    while (num != 0) {
        tmp = num % 10;
        sum += tmp;
        num /= 10;
    }

	return sum;
}
//  [cpp]
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 1; i <= (n); ++i)
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define inf 2147483647 //int値の最大値
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define CST(x) cout<<fixed<<setprecision(x)//小数点以下の桁数指定
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int gcd(int a, int b) {
    if (b==0) return a;
    else return gcd(b, a%b);
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
int two(int n){
	ll ans=1;
	rep(i,n){
		ans*=2;
	}
	return ans;
}
int waru(int n){
    int sum=0;
    while(n>0){
        sum+=n%10;
        n=n/10;
        //sum++;
    }
    return sum;
}
   


int main() {
	cin.tie(0);
	cout.tie(0);
	ios::sync_with_stdio(false);

    int n,a,b;
    cin>>n;
    int min =waru(n-1)+waru(1);

    rep(i,n)FOR(j,i+1,n){
        if(i+j==n && min>waru(i)+waru(j)){
            min =waru(i)+waru(j);
            //cout<<i<<" "<<j<<endl;

        }
    }
cout<<min<<endl;
}
//  [cpp]
#include <bits/stdc++.h>
using namespace std;

int sum(int n){
  int r = 0;
  
  for(int i = 1; i <= 5; i++){
    r += n % 10;
    n /= 10;
  }
  
  return r;
}

int main() {
  int N;
  cin >> N;
  int ans = 0;
  
  int a1 = 1;		// Aの最初の値
  int a2 = N/2;		// Aの最後の値
  int b1 = N/2 + 1;	// Bの最初の値
  int b2 = N - 1;	// Bの最後の値    
  if(N%2 == 0 ){
    b1 = N/2;		// Nが偶数ならBの最初の値を変更
  }
  vector<int> vec(a2);

  for(int i = a1; i <= a2; i++){
    for(int j = b2; j >= b1; j--){
      if( (i + j) == N ) { // A+BがNの値になった場合、AとBの各桁を計算して配列に格納する
        vec.at(i-1) = sum(i) + sum(j);
        break;
      }
    }
  }
 
  // 格納した配列の中で最小の値を求める
  int min = *std::min_element(vec.begin(), vec.end());
  cout << min << endl;
  
  return 0;
}
//  [c]
#include <stdio.h>


int main(){
	int n, s=0;
	scanf("%i", &n);
	if(n%2==0){
		if(n%10==2){
			while(n!=0){
				s=s+n%10;
				n=n/10;
			}
		}
		else{
			n=n/2;
			while(n!=0){
				s=s+n%10;
				n=n/10;
			}
			s=s*2;
		}
	printf("%i\n", s);
	}
	else{
		n--;
		while(n!=0){
			s=s+n%10;
			n=n/10;
		}
		s++;
		printf("%i\n", s);		
	}
}
//  [c]
#include<stdio.h>

int main(){
    int n,ans=0, i,b;
    scanf("%d", &n);
    for(i=0;i<6;i++){
        b = n%10;
        n = n/10;
        ans += b;
    }
    if( ans == 1 ){
        ans = 10;
    }
    printf("%d\n", ans);
    return 0;
}
//  [c]
#include <stdio.h>

int main(void) {

  int n;
  scanf("%d", &n);
  int sum = 0;
  while (n > 0) {
    sum += n%10;
    n /= 10;
  }
  if (sum == 1) {
    sum = 10;
  }
  printf("%d\n", sum);

  return 0;
}
//  [c]
#include<stdio.h>

int main(){
  int n,a,b,i,min=1000,sum=0;
  scanf("%d",&n);
  for(i=1;i<n;i++){
    a=i;
    b=n-i;
    sum=0;
    while(a||b){
      sum+=a%10;
      sum+=b%10;
      a/=10;
      b/=10;
    }
    if(min>sum)
      min=sum;
  }
  printf("%d\n",min);
}
//  [c]
#include <stdio.h>
#include <string.h>

int main(void)
{
    int N;
    int i, j;
    int A, B;
    char Ab[7],Bb[7];
    int ans=90;

    scanf("%d", &N);

    for (i = 1; i <= N/2; i++) {
        A = i;
        B = N - A;
        snprintf(Ab,7,"%d",A);
        snprintf(Bb,7,"%d",B);

        A = 0;
        B = 0;
        for (j = 0; j < strlen(Ab); j++) {
            A+=Ab[j]-'0';
        }
        for (j = 0; j < strlen(Bb); j++) {
            B+=Bb[j]-'0';
        }
        if (ans > A+B)  ans = A+B;
    }
    printf("%d\n", ans);
    return 0;
}
//  [c]
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
void swap_int(int *x, int *y) {int temp;temp = *x;*x = *y;*y = temp;}
void swap_char(char *x, char *y) {char temp;temp = *x;*x = *y;*y = temp;}
int max(int x, int y) { return x > y ? x : y; }
int min(int x, int y) { return x > y ? y : x; }
int fsum(int x){
    char str[1000];
    sprintf(str,"%d",x);
    int sum=0;
    for(int i=0;str[i]!='\0';i++)sum+=str[i]-0x30;
    return sum;
}
int main(){
    int N;
    int a,b;
    int i,j,k;
    int min=999999;

    scanf("%d",&N);

    for(i=1;i<=N/2;i++){
        a=i;
        b=N-a;
        if(min>fsum(a)+fsum(b))min=fsum(a)+fsum(b);
    }
    printf("%d\n",min);
    return 0;
}
//  [javascript]
function Main(input) {
	var n  = input.match(/^10+/)
	if(n!==null) console.log(10);
	else console.log(input[0]-0+(arrsum(input.slice(1,input.length).split("").map(Number))-0));
}Main(require("fs").readFileSync("/dev/stdin", "utf8").trim());
function arrsum(arr){
    var sum = 0;
    for (var i=0,len=arr.length; i<len; ++i) {
        sum += arr[i];
    }
    return sum;
}
//  [javascript]
'use strict'
function main(input) {
  input = input.trim().replace(/(0+)/, '0').split('')
  if (input[input.length - 1] === '0') {
    console.log(Number(input.join('')))
  } else {
    console.log(input.reduce((r, c) => Number(r) + Number(c), 0))
  }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));
//  [javascript]
"use strict"

const main = arg => {
  const digits = arg.toString().length;
  let input = parseInt(arg.trim());

  let divisor = Math.pow(10, digits - 1);
  let arr = [];
  
  for (var i = 0; i < digits; i++) {
  	arr.push(Math.floor(input / divisor))
  	input = input % divisor;
  	divisor /= 10;
  }
  
  let answer = arr.reduce((a, b) => a + b);
  if(answer == 1) {answer = 10;}

  console.log(answer);

}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));
//  [javascript]
'use strict'

function Main(input) {
  const list = input.split("").map(x => Number(x));
  let total = 0;

  for(let i=0; i<list.length; i++) {
    total += list[i];
  }

  if(total === 1) {
    console.log(10);
  } else {
    console.log(total);
  }

}

Main(require("fs").readFileSync("/dev/stdin", "utf8").trim());
//  [javascript]
function main(input) {
  var digits = input.toString().length;
  var input = parseInt(input, 10);
 
  var divisor = Math.pow(10, digits - 1);
  var arr = [];
  for (var i = 0; i < digits; i++) {
  	arr.push(Math.floor(input / divisor))
  	input = input % divisor;
  	divisor /= 10;
 
  }
  var answer = arr.reduce((a, b) => a + b);
  if(answer == 1) {answer = 10;}
 
  console.log(answer);
 
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));
//  [javascript]
function Main(input){

input=parseInt(input);
answer = 100000;
a = input - 1;
b = 1

for (; a > 0; a--,b++) {
    sum = 0;
    aa = a.toString(10);
    ak = aa.length - 1;
    bb = b.toString(10);
    bk = bb.length - 1;
    for (; ak >= 0; ak--) {
        sum = sum + parseInt(aa[ak]);
    }
    for (; bk >= 0; bk--) {
        sum = sum + parseInt(bb[bk]);
    }
    if (sum < answer) {
        answer = sum;
    }
}

console.log(answer);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [go]
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

var (
	rdr   = bufio.NewReaderSize(os.Stdin, 1000000)
	reply string
)

func main() {
	var ans int
	n := atoi(nextSlice())
	for _, a := range n {
		ans += a
	}
	if ans == 1 {
		ans *= 10
	}
	fmt.Println(ans)
}

func readLine() string {
	buf := make([]byte, 0, 1000000)
	for {
		l, p, e := rdr.ReadLine()
		if e != nil {
			panic(e)
		}
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}

func nextSlice() []string {
	return strings.Split(readLine(), "")
}

func atoi(a []string) (b []int) {
	b = make([]int, len(a))
	for i := range a {
		b[i], _ = strconv.Atoi(a[i])
	}
	return
}

func atof(a []string) (b []float64) {
	b = make([]float64, len(a))
	for i := range a {
		b[i], _ = strconv.ParseFloat(a[i], 64)
	}
	return
}

func scanSlice2(n int) (a []int, b []int) {
	a = make([]int, n)
	b = make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&a[i], &b[i])
	}
	return
}

func scanFloatSlice2(n int) (a []float64, b []float64) {
	a = make([]float64, n)
	b = make([]float64, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&a[i], &b[i])
	}
	return
}

// ---------------------------------------------------

func abs(a int) int {
	if a > 0 {
		return a
	}
	return -a
}

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

func min(a ...int) int {
	min := a[0]
	for i := 1; i < len(a); i++ {
		if min > a[i] {
			min = a[i]
		}
	}
	return min
}

func max(a ...int) int {
	max := a[0]
	for i := 1; i < len(a); i++ {
		if max < a[i] {
			max = a[i]
		}
	}
	return max
}

func sum(a []int) (ans int) {
	for i := range a {
		ans += a[i]
	}
	return
}

// ---------------------------------------------------

func yesOrNo(b bool) {
	if b {
		reply = "Yes"
		fmt.Println(reply)
		return
	}
	reply = "No"
	fmt.Println(reply)
}

func yesorNO(b bool) {
	if b {
		reply = "YES"
		fmt.Println(reply)
		return
	}
	reply = "NO"
	fmt.Println(reply)
}
//  [go]
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
)

func main() {
	defer stdout.Flush()
	N := readInt()
	ans := 0
	for N > 0 {
		ans += N % 10
		N /= 10
	}
	if ans == 1 {
		ans = 10
	}
	println(ans)
}

var (
	readString func() string
	stdout     *bufio.Writer
)

func init() {
	readString = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

func readInt() int {
	i, err := strconv.Atoi(readString())
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readIntSlice(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = readInt()
	}
	return b
}

func readLengthAndSlice() []int {
	n := readInt()
	return readIntSlice(n)
}

func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(stdout, f, args...)
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdout, args...)
}
//  [go]
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	//	"strings"
)

func main() {
	sc := NewScanner()

	n := sc.NextInt()

	if n%10 == 0 {
		fmt.Printf("10\n")
		return
	}

	ans := 0
	for true {
		if n < 10 {
			ans += n
			break
		}
		ans += n % 10
		n = n / 10
	}

	fmt.Printf("%v\n", ans)

}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			result = append(result, v)
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	result = append(result, v)

	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}
//  [go]
///
// File:  a.go
// Author: ymiyamoto
//
// Created on Sun Jun  3 21:07:03 2018
//
package main

import (
	"fmt"
	"strconv"
)

var N int

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func main() {
	fmt.Scan(&N)

	v := 1 << 30
	for i := 1; i < N; i++ {
		var val int
		s := strconv.Itoa(i)
		for j := range s {
			val += int(s[j] - '0')
		}
		s = strconv.Itoa(N - i)
		for j := range s {
			val += int(s[j] - '0')
		}
		v = min(v, val)
	}

	fmt.Println(v)
}
//  [go]
package main
import (
  "fmt"
  "strconv"
)
func main() {
  var n,m,t int
  fmt.Scan(&n)
  m = 100000000
  for a:=1;a<=n/2;a++ {
    b := n-a
    t = f(a)+f(b)
    if m > t { m = t }
  }
  fmt.Println(m)
}
func f(x int) int {
  var s string
  var m,t int
  s = strconv.Itoa(x)
  m = 0
  for i:=0;i<len(s);i++ {
    t,_ = strconv.Atoi(s[i:i+1])
    m += t
  }
  return m
}
//  [ruby]
#input of int(split by space)
def get_i()
  return gets.chomp.split(" ").map(&:to_i)
end
#input of float(split by space)
def get_f()
  return gets.chomp.split(" ").map(&:to_f)
end
#input of string(split by space)
def get()
  return gets.chomp.split(" ")
end
#input of string(split per one character)
def get_nsp()
  return gets.chomp.split("")
end
#yes or no decision
def yn_judge(bool,y="Yes",n="No")
  return bool ? y : n 
end
#create of array
def array(size1,init=nil,size2=-1)
  if size2==-1
    return Array.new(size1){init}
  else
    return Array.new(size2){Array.new(size1){init}}
  end
end

def max(a,b)
    return a>b ? a : b
end

def min(a,b)
    return a>b ? b : a
end

INF=Float::INFINITY

N=get_nsp.map(&:to_i)
ans=N.inject(:+)
if ans==1 and N.size>1
    puts 10
else
    puts ans
end
//  [ruby]
s = gets.chomp

if s[0] == '1' and s[1..-1] == '0'*(s.size-1)
    ans = 10
else
    ans = 0
    s.size.times do |i| ans += s[i].to_i end
end

puts ans
//  [ruby]
n = gets.to_i
t = (n - 1).to_s.length
res = []
d = 1
t.times do |_|
  s = (d.to_s + (n - d).to_s).chars.map(&:to_i).inject(:+)
  res << s
  d *= 10
end
puts res.min
//  [ruby]
n = gets.to_i

answer = [*1..(n - 1)].map {|a|
  [a, n - a].map {|b| 
    b.to_s.split('').map(&:to_i).reduce(:+)
  }.reduce(:+)
}.min

puts answer
//  [ruby]
n = gets.to_i

ans = 1000000000

(1..n-1).each do |i|
  other = n - i
  ans = [ans, i.to_s.split('').map(&:to_i).inject(&:+) + other.to_s.split('').map(&:to_i).inject(&:+)].min
end

puts ans
//  [ruby]
n=gets.to_i
array=[]
def sum_of_digits(c)
   c.to_s.split("").map { |s| s.to_i }.inject(:+)
end
 n.times do |a|
 b=n-a
 array.push(sum_of_digits(b)+sum_of_digits(a))
 a+=1
 end
array.delete(1)
p array.min
//  [rust]
use std::io::stdin;

fn main() {
    let mut st = String::new();
    stdin().read_line(&mut st).unwrap();
    let n:Vec<char> = st.trim().chars().collect();
    let mut r:Vec<i32> = Vec::new();
    for i in 0..n.len() {
        r.push(n[i] as i32);
        let x:&mut i32 = r.last_mut().unwrap();
        *x -= 48;
    }
    let mut result = 0;
    for i in r {
        result += i;
    };
    if result == 1 {
        result = 10;
    };
    println!("{}", result);
}
//  [rust]
use std::io;


/// https://beta.atcoder.jp/contests/agc025/tasks/agc025_a
fn main() {
    let n = read_one::<usize>();
    let mut x = n;
    let mut flg = true;
    while x > 1 {
        if x % 10 != 0 { flg = false; }
        x = x / 10;
    }

    if !flg {
        let mut x = n;
        let mut sum = 0;
        while x > 0 {
            sum += x % 10;
            x = x / 10;
        }
        println!("{}", sum);
    } else { println!("10"); }
}


#[allow(dead_code)]
fn read<T>() -> Vec<T>
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.split_whitespace()
        .map(|s| s.trim().parse().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_one<T>() -> T
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().unwrap()
}
//  [rust]
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
  let _a: f64 = read();
  let a: u32 = _a as u32;
  let b = 10f64.powi(_a.log10() as i32) as u32;
  if a == b {
    println!("{}", 10);
  } else {
    println!("{}", sum_digit_num(a));
  }
}

fn sum_digit_num(a: u32) -> u32{
  let mut b = a/10*10;
  let mut diff = a-b;
  let mut res = diff;
  let mut x = a/10;
  loop {
    b = x/10*10;
    diff = x-b;
    res += diff;
    if b == 0 { break;}
    x = x/10;
  }
  return res
}
//  [rust]
extern crate core;

use std::io::{self, Read};

#[macro_use]
mod parser {
    macro_rules! input {
    ($s:expr=>$($t:tt)*) => {
        let mut lines=$s.split("\n");
        $(
            line_parse!(lines,$t);
        )*
    };
    }

    macro_rules! line_parse {
    ($lines:expr,($($name:ident:$t:tt)*)) => {
        let mut line=$lines.next().unwrap().split_whitespace();
        $(value_def!(line,$name,$t);)*
    };

    //複数行
    ($lines:expr,{$n:expr;$name:ident:$t:tt}) => {
        values_def!($lines,$n,$name,$t);
    };
    }

    macro_rules! value_def {
        ($line:expr, $name:ident, $t:tt) => {
            let $name = value!($line, $t);
        };
    }

    macro_rules! values_def {
        ($lines:expr, $n:expr, $name:ident, $t:tt) => {
            let $name = {
                let mut vec = Vec::new();
                for i in 0..$n {
                    let mut next = $lines.next().unwrap().split_whitespace();
                    vec.push(value!(next, $t));
                }
                vec
            };
        };
    }

    macro_rules! value {
    //配列
    ($line:expr,[$t:tt]) => {
        $line.map(|x|{
        let mut iter=::std::iter::once(x);
        value!(iter,$t)
        }).collect::<Vec<_>>()
    };
    //タプル
    ($line:expr,($($t:tt),*)) => {
        ($(value!($line,$t),)*)
    };
    //文字列
    ($line:expr,#) => {
        $line.next().unwrap()
    };
    //単一値
    ($line:expr,$t:ty) => {
        $line.next().unwrap().parse::<$t>().unwrap()
    };
    }
}

fn main() {
    let mut input = String::new();
    io::stdin().read_to_string(&mut input).unwrap();
    let output = solve(input.trim().to_string());
    println!("{}", output);
}

fn solve(input: String) -> String {
    input!(input=>(n:i64));
    (1..n)
        .map(|x| (x, n - x))
        .map(|(a, b)| f(a) + f(b))
        .min()
        .unwrap()
        .to_string()
}

fn f(n: i64) -> i64 {
    n.to_string()
        .chars()
        .map(|x| x.to_string().parse::<i64>().unwrap())
        .sum()
}

macro_rules! tests {
    ($($name:ident: $input:expr=>$output:expr,)*) => {
        mod tests {
            $(
                #[test]
                fn $name() {
                    assert_eq!($output.trim().to_string(),super::solve($input.trim().to_string()));
                }
            )*
        }
    }
}

tests! {
    test1: "15" => "6",
    test2: "100000" => "10",
}
//  [rust]
fn getline() -> String{
    let mut __ret=String::new();
    std::io::stdin().read_line(&mut __ret).ok();
    return __ret;
}

fn main(){
    let s=getline();
    let a:Vec<_>=s.trim().split(' ').collect();
    let n:i32=a[0].parse().unwrap();

    let mut min_sum = -1;
    for a in 1..n{
        let b = n-a;
        let a_str = format!("{:?}", a);
        let b_str = format!("{:?}", b);
        let mut sum:i32 = 0;
        for c in a_str.chars(){
            let x = format!("{}", c);
            let s:i32 =  x.parse().unwrap();
            sum += s;
        }
        for c in b_str.chars(){
            let x = format!("{}", c);
            let s:i32 =  x.parse().unwrap();
            sum += s;
        }
        if(min_sum < 0){
            min_sum = sum;
        }
        else{
            if(min_sum > sum){
                min_sum = sum;
            }
        }
    }
    println!("{} ",min_sum);
}
//  [rust]
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}
fn digit_sum(n:i64) -> i64{
    let mut a = n;
    let mut res = 0;
    let mut ten = 1;
    loop {
        res += a%(ten*10)/ten;
        a -= a%ten;
        if a==0 {
            break;
        }
        ten*=10;
    }
    // println!("{} {}", n, res);
    res
}
fn main() {
    input!{
        n:i64
    }
    let mut ans: i64 = 1<<50;
    for a in 1..n {
        ans = std::cmp::min(ans, digit_sum(a) + digit_sum(n-a));
    }
    println!("{}", ans);
}
//  [swift]
import Foundation

let N = Int(readLine()!)!
var answer = 0
var lengthOfN = 0

func power(_ x: Int, _ n: Int) -> Int {
  var result = 1
  if n >= 1 {
    for _ in 1...n {
      result *= x
    }
  }
  return result
}

if N % 10 == 0 {
  answer = 10
} else {
  var tN = N
  while tN != 0 {
    tN /= 10
    lengthOfN += 1
  }
  tN = N
  var i = lengthOfN, j: Int
  while i > 0 {
    i -= 1
    j = power(10, i)
    answer += tN / j
    tN %= j
  }
}

print(answer)
//  [swift]
let rd = Int(readLine()!)!
func sumDigits(_ num: Int) -> Int {
  var num = num
  var sum = 0
  while num > 0 {
    sum += num%10
    num /= 10
  }
  return sum
}

var min = 100
for i in 1 ... rd/2+1 {
  var j = rd - i
  if sumDigits(i) + sumDigits(j) < min {
    min = sumDigits(i) + sumDigits(j)
  }
}
print(min)
//  [swift]
let N=Int(readLine()!)!
func f(i:Int)->Int{return "\(i)\(N-i)".characters.reduce(0){$0+Int("\($1)")!}}
print((1...N/2).reduce(90){min($0,f($1))})
//  [typescript]
const log = console.log;

const findBestRecordInteger = (
  start: number,
  end: number,
  getRecord: (n: number) => number,
  isBetterRecord: (record: number, currentBestRecord: number) => boolean
) => {
  let bestRecord = getRecord(start);
  let bestRecordNumber = start;

  for (let i = start + 1; i < end; i += 1) {
    const currentRecord = getRecord(i);

    if (!isBetterRecord(currentRecord, bestRecord)) continue;

    bestRecord = currentRecord;
    bestRecordNumber = i;
  }

  return {
    record: bestRecord,
    num: bestRecordNumber
  };
};

const sumDigits = (v: number, base = 10) => {
  let accumulator = 0;

  while (v > 0) {
    accumulator += v % base;
    v = (v / base) | 0;
  }

  return accumulator;
};

// ----

function Main(input: string): void {
  const n = +input;

  const minValue = findBestRecordInteger(
    1,
    n,
    num => sumDigits(num) + sumDigits(n - num),
    (num, currentMinNum) => num < currentMinNum
  ).record;

  log(minValue);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [python]
#coding:utf-8
n = int(input())
List = list(map(int,input().split()))
print(sum(List) - n)
//  [python]
N = int(input())
A_list = list(map(int, input().split()))

print(sum(A_list) - N)
//  [python]
N = int(input())
a = list(map(int, input().split()))
print(sum(a)-len(a))
//  [python]
from numpy import *
from scipy import *
from sys import *

n = int(input())
a = array(list(map(int, input().split())))

print(sum(a)-n)
//  [python]
from functools import reduce
N = int(input())
a = list(map(int, input().split()))

def gcd_impl(n,m):
    K = 5
    for _ in range(80):
        t = n - m
        s = n - m*K
        q = t < m
        p = t < m*K
        if q:
            n = m
        else:
            n = t
        if q:
            m = t
        else:
            m = m
        if m == 0:
            return n
        if p:
            n = n
        else:
            n = s
    return gcd_impl(m, n%m)

def gcd_pre(n,m):
    for _ in range(4):
        t = n - m
        q = t < m
        if q:
            n = m
        else:
            n = t
        if q:
            m = t
        else:
            m = m
        if m == 0:
            return n
    return gcd_impl(n,m)

def gcd(n,m):
    if n > m:
        return gcd_pre(n,m)
    else:
        return gcd_pre(m,n)

def lcm(a,b):
    return (a*b)//gcd(a,b)

def lcm_list(lst):
    return reduce(lcm, lst)

M = lcm_list(a) - 1

res = 0
for i in a:
    res += M%i
print(res)
//  [python]
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
inf = float('inf')
ninf = -float('inf')
 
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#https://atcoder.jp/contests/abc103/tasks/abc103_c
from fractions import gcd
from functools import reduce
def lcm_base(x, y):
    return (x * y) // gcd(x, y)
#list
def lcm(numbers):
    return reduce(lcm_base, numbers, 1)

n=ii()
arr=limii()
p=lcm(arr)-1

ans=0
for i in range(n):
    ans+=p%arr[i]
print(ans)
//  [java]
import java.util.*;
import java.io.*;

public class Main{

	public static void main(String[] args) throws IOException {
		int N = readInt(); long sum = 0; for(int i= 1; i<=N; i++) sum += readInt()-1; println(sum); exit();
	}

	final private static int BUFFER_SIZE = 1 << 16;
	private static DataInputStream din = new DataInputStream(System.in);
	private static byte[] buffer = new byte[BUFFER_SIZE];
	private static int bufferPointer = 0, bytesRead = 0;
	static PrintWriter pr = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));

	public static String readLine() throws IOException {
		byte[] buf = new byte[64]; // line length
		int cnt = 0, c;
		while ((c = Read()) != -1) {
			if (c == '\n')
				break;
			buf[cnt++] = (byte) c;
		}
		return new String(buf, 0, cnt);
	}

	public static String read() throws IOException {
		byte[] ret = new byte[1024];
		int idx = 0;
		byte c = Read();
		while (c <= ' ') {
			c = Read();
		}
		do {
			ret[idx++] = c;
			c = Read();
		} while (c != -1 && c != ' ' && c != '\n' && c != '\r');
		return new String(ret, 0, idx);
	}

	public static int readInt() throws IOException {
		int ret = 0;
		byte c = Read();
		while (c <= ' ')
			c = Read();
		boolean neg = (c == '-');
		if (neg)
			c = Read();
		do {
			ret = ret * 10 + c - '0';
		} while ((c = Read()) >= '0' && c <= '9');

		if (neg)
			return -ret;
		return ret;
	}

	public static long readLong() throws IOException {
		long ret = 0;
		byte c = Read();
		while (c <= ' ')
			c = Read();
		boolean neg = (c == '-');
		if (neg)
			c = Read();
		do {
			ret = ret * 10 + c - '0';
		} while ((c = Read()) >= '0' && c <= '9');
		if (neg)
			return -ret;
		return ret;
	}

	public static double readDouble() throws IOException {
		double ret = 0, div = 1;
		byte c = Read();
		while (c <= ' ')
			c = Read();
		boolean neg = (c == '-');
		if (neg)
			c = Read();

		do {
			ret = ret * 10 + c - '0';
		} while ((c = Read()) >= '0' && c <= '9');

		if (c == '.') {
			while ((c = Read()) >= '0' && c <= '9') {
				ret += (c - '0') / (div *= 10);
			}
		}

		if (neg)
			return -ret;
		return ret;
	}

	private static void fillBuffer() throws IOException {
		bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);
		if (bytesRead == -1)
			buffer[0] = -1;
	}

	private static byte Read() throws IOException {
		if (bufferPointer == bytesRead)
			fillBuffer();
		return buffer[bufferPointer++];
	}

	static void print(Object o) {
		pr.print(o);
	}

	static void println(Object o) {
		pr.println(o);
	}

	static void flush() {
		pr.flush();
	}

	static void println() {
		pr.println();
	}

	static void exit() throws IOException {
		din.close();
		pr.close();
		System.exit(0);
	}
}
//  [java]
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		int N = sc.nextInt();
		int ans = 0;
		for (int i = 0; i < N; i++) {
			ans += sc.nextInt() - 1;
		}
		System.out.println(ans);
	}



	public static long gcd(long a, long b) {
		long remainder = a % b;
		if (remainder == 0) {
			return b;
		} else {
			return gcd(b, remainder);
		}
	}
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }

    private int readByte() {
        if (hasNextByte())
            return buffer[ptr++];
        else
            return -1;
    }

    private static boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr]))
            ptr++;
        return hasNextByte();
    }

    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public long nextLong() {
        if (!hasNext())
            throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }

    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
            throw new NumberFormatException();
        return (int) nl;
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }
}
//  [java]
import java.math.BigInteger;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		BigInteger A[] = new BigInteger[N];
		BigInteger m = A[0] = new BigInteger(sc.next());
		BigInteger gcd;

		for (int i = 1; i < N; i++) {
			A[i] = new BigInteger(sc.next());
			gcd = A[i].gcd(m);
			m = A[i].multiply(m).divide(gcd);
		}

		m = m.subtract(BigInteger.ONE);

		BigInteger fMax = BigInteger.ZERO;

		for (int i = 0; i < N; i++) {
			fMax = fMax.add(m.remainder(A[i]));
		}

		System.out.println(fMax);

		return;
	}
}
//  [java]
import java.math.BigInteger;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		BigInteger[] num = new BigInteger[n];
		BigInteger tmp = BigInteger.ONE;
		for(int i = 0; i < n; i++) {
			num[i] = new BigInteger(sc.next());
			tmp = tmp.divide(tmp.gcd(num[i]));
			tmp = tmp.multiply(num[i]);
		}
		tmp = tmp.subtract(BigInteger.ONE);
		BigInteger ans = BigInteger.ZERO;
		for(int i = 0; i < n; i++) {
			ans = ans.add(tmp.mod(num[i]));
		}
		System.out.println(ans.toString());
	}
}
//  [cpp]
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
using namespace std;
int n, x, ans;
int main(){
	scanf("%d", &n);
	for(int i = 1; i <= n; ++i){
		scanf("%d", &x);
		ans += x;
	}
	printf("%d\n", ans - n);
	return 0;
}
//  [cpp]
/*input
7
994 518 941 851 647 2 581
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout << (#x) << " is " << (x) << endl
#define debug cout << "hi" << endl

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

const int MOD = 1e9 + 7;
const int INF32 = 1<<30;
const ll INF64 = 1LL<<60;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n; cin >> n;
    int ans = 0;
    for(int i = 0; i < n; i++)
    {
    	int a; cin >> a;
    	ans += a - 1;
    }
    cout << ans;

    return 0;
}
//  [cpp]
// #pragma GCC optimize(3, "Ofast", "inline")
#include <bits/stdc++.h>
#define String std::string
#define fi first
#define se second
#define mp std::make_pair
#define Pair std::pair<int, int>
#define Map std::map< int, int >
#define Vector std::vector<int>
 
using std::cin;
using std::cout;
using std::endl;
 
typedef long long ll;
typedef unsigned long long ull;
 
const int N = 100000 + 5;
const int M = 1000 + 5;
const int K = 1e7 + 5;
const int MOD = 1e9 + 7;
const int inv2 = 500000004;
const int LOG = 40;
const ull BASE = 19260817;
const int dx[] = { 0, 1, -1, 0, 1, -1, 1, -1 };
const int dy[] = { 1, 0, 0, -1, 1, -1, -1, 1 };
const double PI = acos(-1);

template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }
 
template<class T>
inline T readT() {
    T res = 0, f = 1;
    char ch = getchar();
    for (; !isdigit(ch); ch = getchar()) if (ch == '-') f = -1;
    for (; isdigit(ch); ch = getchar()) res = (res << 1) + (res << 3) + ch - '0';
    return res * f;
}
#define read readT<int>

int n, x, ans;

int main() {
    n = read();
    for (int i = 1; i <= n; i++) { x = read(); ans += x - 1; }
    printf("%d\n", ans);
    return 0;
}
//  [cpp]
#include<bits/stdc++.h>
using namespace std;
using ll = int64_t;
ll gcd(ll a, ll b){return b ? gcd(b, a % b) : a;}
int main(){
    ll N;
    cin >> N;
    ll ans = 0;
    ll a[N];
    for(ll i = 0; i < N; i++) cin >> a[i];
    for(ll i = 0; i < N; i++){
        ll b = a[i] - 1;
        ll tmp = 0;
        for(ll j = 0; j < N; j++){
            ll g = gcd(a[i], a[j]);
            tmp += a[j] - g + b % g;
        }
        ans = max(ans, tmp);
    }
    cout << ans << endl;
    return 0;
}
//  [cpp]
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;

bool sieve[35005];
LL datas[3005];
vector<int> prime;
void fill(int N)
{
	for(int a=2;a*a<=N;a++)
	{
		if(!sieve[a])
		{	
			for(int b=a;b*a<=N;b++)
			{
				sieve[b*a]=1;
			}
		}
	}
	for(int a=2;a<=N;a++)
	{
		if(!sieve[a]) prime.pb(a);
	}
}

vector<LL> S;

void factorize(int N)
{
	int ix=0;
	while(N>1 && ix<prime.size())
	{
		while(N%prime[ix]==0)
		{
			S.pb(prime[ix]);
			N/=prime[ix];
		}
		ix++;
	}
	if(N > 1) S.pb(prime[ix]);
}

int main()
{
	fill(35000);
	int n;
	scanf("%d", &n);
	LL tr=1;
	for(int a=0;a<n;a++)
	{
		scanf("%lld", &datas[a]);
		factorize(datas[a]);
	}
	LL hasil=0;
	for(int a=0;a<n;a++)
	{
		LL tmp=1;
		for(int z=0;z<S.size();z++)
		{
			tmp=(tmp*S[z])%datas[a];
		}
		tmp=(tmp-1+datas[a])%datas[a];
		hasil+=tmp;
	}
	printf("%lld\n", hasil);
	return 0;
}
//  [cpp]
#include <bits/stdc++.h>

using namespace std;
#define N 101010
#define F first
#define S second

typedef long long ll;
typedef pair<int, int> ii;


int n, v[N], c[N], lst[N];

void crivo(){
	for(int i=2; i<N; i++){
		if(!lst[i]){
			for(int j=i; j<N; j+=i) lst[j]=i;
		}
	}
}

void f(int x){
	int p;
	while(x!=1){
		p = lst[x];
		int cnt=0;
		while(x%p==0) x/=p, cnt++;
		c[p] = max(c[p], cnt);
	}
}

int main(){
	
	crivo();
	scanf("%d", &n);
	for(int i=0; i<n; i++) {
		scanf("%d", &v[i]);
		f(v[i]);
	}
	int ans=0;
	for(int a = 0; a<n; a++){
		
		int aux=1;
		for(int i=2; i<N; i++){
			if(!c[i]) continue;
			for(int k=0; k<c[i]; k++){
				aux = (aux*1LL*i)%v[a];
			}
		}
		
		aux = (aux - 1 + v[a])%v[a];
		ans+=aux;
	}
	
	printf("%d\n", ans);
}
//  [c]
#include<stdio.h>
int main()
{
int max,a,i,ans;
  scanf("%d",&a);
int b[a];

  ans=0;
  
  for(i=0;i<a;++i)
  {scanf("%d",&b[i]);
   ans=ans+b[i]-1;
  }

  
  printf("%d",ans);
  
return 0;
}
//  [c]
#include<stdio.h>
int main(void){
int N,a[10000], sum=0;
scanf("%d", &N);
for(int i=0;i<N;i++){
    scanf("%d",&a[i]);
    sum+=a[i];
}
printf("%d\n",sum-N);
return 0;
}
//  [c]
#include <stdio.h>
#include <stdlib.h>

int main()
{
	int i, N, a[3001];
	scanf("%d", &N);
	for (i = 1; i <= N; i++) scanf("%d", &(a[i]));
	
	long long sum = 0;
	for (i = 1; i <= N; i++) sum += a[i];
	
	printf("%d\n", sum - N);
	fflush(stdout);
	return 0;
}
//  [c]
#include<stdio.h>
#include<string.h>
int main()
{
    int n, sum=0, temp, i;
    scanf("%d", &n);
    i=0;
    while(i<n)
    {
        scanf("%d", &temp);
        sum += temp;
        i++;
    }
    sum = sum-n;
    printf("%d\n", sum);
}
//  [c]
#include<stdio.h>
int main()
{
    int n,s=0,a,i;
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
        scanf("%d",&a);
        s+=a;
    }
    s-=n;
    printf("%d\n",s);
    return 0;
}
//  [c]
#include<stdio.h>
int main()
{
      long long int n=0,i,a,b;
      scanf("%lld",&a);
      for(i=1;i<=a;i++){
      scanf("%lld",&b);
      n=n+b;
      }
      printf("%lld\n",n-a);




      return 0;
}
//  [javascript]
function Main(input) {
  input = input.trim();
  input = input.split("\n");
  var sum=0;
  arr = input[1].split(" ").map(Number);
  for(var i=0;i<input[0];i++){
    sum+=arr[i]-1;
  }
  console.log(sum);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [javascript]

// inputに入力データ全体が入る
function Main(input) {
	var n = input.split("\n")[0];
	var ans = 0;
	input.split("\n")[1].split(" ").forEach(v=>{ans+=parseInt(v)-1});
	console.log(ans);
	
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [javascript]
console.log(eval(("-"+require("fs").readFileSync(0)+0).replace(/\s/g,"+")))
//  [javascript]
function main(input) {
    var array = input.split('\n');
    var numbers=array[1].split(' ');
    var counter = 0;

    for(i=0; i< numbers.length; i++){
        counter += numbers[i]-1;
    }
    
    console.log(counter);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));
//  [javascript]
'use strict';

function Main(input) {
  const N = Number(input.split('\n')[0]);
  const T = input.split('\n')[1].split(' ').map(x => Number(x));

  const total = T.reduce((x, y) => x + y) - N;

  console.log(total);

};

Main(require("fs").readFileSync("/dev/stdin", "utf8").trim());
//  [javascript]
function main(input) {
    var arr = []
    var input = input.split("\n")
    input = input[1].split(" ")
  
    var v = 0
    for (var k in input) {
      v += Number(input[k])
    }
  	v -= input.length
  	console.log(v)
  }
  main(require('fs').readFileSync('/dev/stdin', 'utf8'));
//  [go]
package main
import(
  "fmt"
  "bufio"
  "os"
  "strconv"
)
var sc=bufio.NewScanner(os.Stdin)
func nextInt() int{
  sc.Scan()
  i, e :=strconv.Atoi(sc.Text())
  if e!=nil{
    panic(e)
  }
  return i
}
func main(){
  var i int
  ans:=0
  sc.Split(bufio.ScanWords)
  n:=nextInt()
  a:=make([]int, n)
  for i=0;i<n;i++{
    a[i]=nextInt()
    ans+=a[i]-1
  }
  fmt.Println(ans)
}
//  [go]
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func lowerBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] >= x
	})
	return idx
}

func upperBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] > x
	})
	return idx
}

// GCD : greatest common divisor (GCD) via Euclidean algorithm
func GCD(a, b int) int {
	for b != 0 {
		t := b
		b = a % b
		a = t
	}
	return a
}

// LCM : find Least Common Multiple (LCM) via GCD
func LCM(a, b int, integers ...int) int {
	result := a / GCD(a, b) * b

	for i := 0; i < len(integers); i++ {
		result = LCM(result, integers[i])
	}

	return result
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer([]byte{}, 1000000)

	N := getInt()
	a := make([]int, N)
	for i := 0; i < N; i++ {
		a[i] = getInt()
	}
	ans := 0
	for i := 0; i < N; i++ {
		ans += a[i] - 1
	}
	out(ans)
}
//  [go]
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func max(nums []int) int {
	ret := nums[0]
	for _, v := range nums {
		if v > ret {
			ret = v
		}
	}
	return ret
}

func minFactors(n int) []int {
	mf := make([]int, n+1)
	mf[0], mf[1] = -1, -1
	for i := 2; i <= n; i++ {
		for j := 1; i*j <= n; j++ {
			if mf[i*j] == 0 {
				mf[i*j] = i
			}
		}
	}
	return mf
}

func primeFactors(a []int) []map[int]int {
	// 各数の素因数分解結果を入れるmap配列
	m := make([]map[int]int, len(a))
	for i := range m {
		m[i] = map[int]int{}
	}
	// 最小素因数テーブル
	mf := minFactors(max(a))
	for i := range a {
		for j := a[i]; j > 1; j /= mf[j] {
			m[i][mf[j]]++
		}
	}
	return m
}

func lcmFactorFast(a []int) map[int]int {
	pfs := primeFactors(a)
	m := map[int]int{}
	for x, y := range pfs[0] {
		m[x] = y
	}
	for i := 1; i < len(a); i++ {
		for x := range pfs[i] {
			if pfs[i][x] > m[x] {
				m[x] = pfs[i][x]
			}
		}
	}
	return m
}

func pow(a, n int) int {
	ret := 1
	for n > 0 {
		if n&1 == 1 {
			ret *= a
		}
		a *= a
		n >>= 1
	}
	return ret
}

func main() {
	sc.Split(bufio.ScanWords)
	n := nextInt()
	a := nextInts(n)

	ans := 0
	lf := lcmFactorFast(a)
	for i := range a {
		f := 1
		for x, y := range lf {
			f = (f * pow(x, y)) % a[i]
		}
		f--
		if f < 0 {
			f = a[i] - 1
		}
		ans += f
	}
	puts(ans)
	wt.Flush()
}

var (
	sc  = bufio.NewScanner(os.Stdin)
	rdr = bufio.NewReaderSize(os.Stdin, 1000000)
	wt  = bufio.NewWriter(os.Stdout)
)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	i, _ := strconv.Atoi(next())
	return i
}

func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(next(), 64)
	return f
}

func nextInts(n int) []int {
	slice := make([]int, n)
	for i := 0; i < n; i++ {
		slice[i] = nextInt()
	}
	return slice
}

func nextFloat64s(n int) []float64 {
	slice := make([]float64, n)
	for i := 0; i < n; i++ {
		slice[i] = nextFloat64()
	}
	return slice
}

func nextMega() string {
	buf := make([]byte, 0, 1000000)
	for {
		l, p, _ := rdr.ReadLine()
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}

func putf(format string, a ...interface{}) {
	fmt.Fprintf(wt, format, a...)
}

func puts(a ...interface{}) {
	fmt.Fprintln(wt, a...)
}