using System;
using System.Collections.Generic;
using System.Linq;
class Program
{
static string InputPattern = "InputX";
static List<string> GetInputList()
{
var WillReturn = new List<string>();
if (InputPattern == "Input1") {
WillReturn.Add("7 5");
WillReturn.Add("2");
WillReturn.Add("1");
WillReturn.Add("1");
WillReturn.Add("3");
WillReturn.Add("2");
WillReturn.Add("1");
WillReturn.Add("2");
WillReturn.Add("-1");
WillReturn.Add("3");
WillReturn.Add("2");
WillReturn.Add("-3");
//18
}
else {
string wkStr;
while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr);
}
return WillReturn;
}
const long Hou = 100000;
static void Main()
{
List<string> InputList = GetInputList();
long[] wkArr = { };
Action<string> SplitAct = pStr =>
wkArr = pStr.Split(' ').Select(pX => long.Parse(pX)).ToArray();
SplitAct(InputList[0]);
long HotelCnt = wkArr[0];
var DistanceList = new List<long>();
foreach (string EachStr in InputList.Skip(1).Take((int)HotelCnt - 1)) {
long Distance = long.Parse(EachStr);
Distance %= Hou;
DistanceList.Add(Distance);
}
// フェニック木
var Ins_Fenwick_Tree = new Fenwick_Tree(DistanceList.Count - 1, Hou);
for (int I = 0; I <= DistanceList.Count - 1; I++) {
Ins_Fenwick_Tree.Add(I, DistanceList[I]);
}
long Answer = 0;
long CurrPos = 0;
foreach (string EachStr in InputList.Skip(1 + (int)HotelCnt - 1)) {
long MoveVect = long.Parse(EachStr);
long NextPos = CurrPos + MoveVect;
long RangeSta = Math.Min(CurrPos, NextPos);
long RangeEnd = Math.Max(CurrPos, NextPos);
RangeEnd--; // 階差なので調整分で終点から1引く
long CurrSum = Ins_Fenwick_Tree.GetSum(RangeSta, RangeEnd);
//Console.WriteLine("RangeSta={0},RangeEnd={1},CurrSum={2}", RangeSta, RangeEnd, CurrSum);
Answer += CurrSum;
Answer %= Hou;
CurrPos = NextPos;
}
Console.WriteLine(Answer);
}
}
// フェニック木
#region Fenwick_Tree
internal class Fenwick_Tree
{
private long[] mBitArr;
private long mExternalArrUB;
private long mHou;
// ノードのIndexの列挙を返す
internal IEnumerable<long> GetNodeIndEnum()
{
for (long I = 0; I <= mExternalArrUB; I++) {
yield return I;
}
}
// 木のノードのUBを返す
internal long GetUB()
{
return mExternalArrUB;
}
// コンストラクタ
internal Fenwick_Tree(long pExternalArrUB, long pHou)
{
mExternalArrUB = pExternalArrUB;
// フェニック木の外部配列は0オリジンで、
// フェニック木の内部配列は1オリジンなため、2を足す
mBitArr = new long[pExternalArrUB + 2];
mHou = pHou;
}
// [pSta,pEnd] のSumを返す
internal long GetSum(long pSta, long pEnd)
{
long Result = GetSum(pEnd) - GetSum(pSta - 1);
Result %= mHou;
if (Result < 0) Result += mHou;
return Result;
}
// [0,pEnd] のSumを返す
internal long GetSum(long pEnd)
{
pEnd++; // 1オリジンに変更
long Sum = 0;
while (pEnd >= 1) {
Sum += mBitArr[pEnd];
Sum %= mHou;
pEnd -= pEnd & -pEnd;
}
if (Sum < 0) Sum += mHou;
return Sum;
}
// [I] に Xを加算
internal void Add(long pI, long pX)
{
pI++; // 1オリジンに変更
pX %= mHou;
while (pI <= mBitArr.GetUpperBound(0)) {
mBitArr[pI] += pX;
mBitArr[pI] %= mHou;
pI += pI & -pI;
}
}
}
#endregion