This documentation is automatically generated by online-judge-tools/verification-helper
import cp_library.math.series.__header__
def arthsum(d, a, n, mod):
return (((n-1)*d+(a<<1)) % mod * n >> 1) % mod
'''
╺━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╸
https://kobejean.github.io/cp-library
'''
def arthsum(d, a, n, mod):
return (((n-1)*d+(a<<1)) % mod * n >> 1) % mod