#include <stdio.h>
#import <Foundation/Foundation.h>

int main(int argc, const char * argv[]) {
    int N;
    scanf("%d", &N);
    NSMutableArray *numbers = [[NSMutableArray alloc] initWithCapacity:N];
    NSMutableArray *mods = [[NSMutableArray alloc] initWithCapacity:N];
    int i = 0;
    for(i=0;i<N;i++) {
        [numbers addObject:[NSNumber numberWithInt:i+1]];
        [mods addObject:[NSNumber numberWithInt:0]];
    }
    int j=0;
    for(i=0;i<N;i++){
        for(j=0;j<N;j++) {
            NSInteger modi = [(NSNumber *)numbers[i] integerValue];
            NSInteger modj = [(NSNumber *)numbers[j] integerValue];
            if ([(NSNumber *)mods[i] integerValue] < modi % modj) {
                mods[j] = [NSNumber numberWithInt:modi % modj];
            }
            NSLog(@"%@", mods);
        }
    }
    
    NSInteger result = 0;
    for(NSNumber *mod in mods) {
        result += mod.integerValue;
    }
    printf("%d", result);
    return 0;
}
