#include<bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
#define read(v)for(auto &i:v)cin>>i
#define pv(v)for(auto i:v)cout<<i<<" ";cout<<endl
#define pii pair<int,int>
using namespace std;
struct item{
int c1,c2,c3,c4;
};
struct segmentTree{
int size;
item NEUTRAL_ELEMENT = {1,0,0,1};
vector<item>seg;
void init(int n){
size = 1;
while(size<n)size*=2;
seg.resize(2*size,NEUTRAL_ELEMENT);
}
void build(vector<item>&a,int index,int lx,int rx){
if(rx-lx==1){
if(lx<(int)(a.size())){
seg[index] = a[lx];
}
return;
}
int mid = (lx+rx)/2;
build(a,2*index+1,lx,mid);
build(a,2*index+2,mid,rx);
seg[index] = merge(seg[2*index+1],seg[2*index+2]);
}
void build(vector<item>&v){
build(v,0,0,size);
}
int calc(int a,int b){
return (a*b)%mod;
}
item merge(item a,item b){
item result = NEUTRAL_ELEMENT;
result.c1 = (calc(a.c1,b.c1)+calc(a.c2,b.c3))%mod;
result.c2 = (calc(a.c1,b.c2)+calc(a.c2,b.c4))%mod;
result.c3 = (calc(a.c3,b.c1)+calc(a.c4,b.c3))%mod;
result.c4 = (calc(a.c3,b.c2)+calc(a.c4,b.c4))%mod;
return result;
}
// void update(int i,int v,int index,int lx,int rx){
// if(rx-lx==1){
// seg[index] = v;
// return;
// }
// int mid = (lx+rx)/2;
// if(i<mid)update(i,v,2*index+1,lx,mid);
// else update(i,v,2*index+2,mid,rx);
// seg[index] = merge(seg[2*index+1],seg[2*index+2]);
// }
// void update(int i,int v){
// return update(i,v,0,0,size);
// }
item query(int l,int r,int index,int lx,int rx){
if(lx>=l && rx<=r)return seg[index];
if(rx<=l || lx>=r)return NEUTRAL_ELEMENT;
int mid = (lx+rx)/2;
item left = query(l,r,2*index+1,lx,mid);
item right = query(l,r,2*index+2,mid,rx);
return merge(left,right);
}
item query(int l,int r){
return query(l,r,0,0,size);
}
void printSegment(){
for(auto i:seg)cout<<i.c1<<" "<<i.c2<<" "<<i.c3<<" "<<i.c4<<endl;
}
int mod;
};
// bool evenExists(vector<int>v){
// int n = v.size();
// int odd = INT_MAX;
// for(auto i:v){
// if(i%2==1)odd = min(odd,i);
// }
// for(int i=1;i<n;i++){
// if(v[i]%2==0){
// continue;
// }
// else{
// if(odd==INT_MAX)return false;
// else if(v[i]-odd>0)continue;
// else if(v[i]-odd<=0)return false;
// }
// }
// return true;
// }
int bfs(int node,vector<vector<pair<int,int>>>&adj,vector<pair<bool,int>>&vis,int prev){
queue<pair<int,int>>q;
vis[node].first = true;
vis[node].second = 0;
q.push({node,0});
int count = 0;
while(!q.empty()){
int n = q.size();
for(int i=0;i<n;i++){
int node = q.front().first,time = q.front().second;
if(vis[node].second==INT_MAX)vis[node].second = time;
q.pop();
for(auto i:adj[node]){
int neighbourNode = i.second,neighbourTime = i.first;
if(!vis[neighbourNode].first){
vis[neighbourNode].first = true;
if(neighbourTime<vis[node].second){
vis[node].second = neighbourTime;
count++;
}
q.push({neighbourNode,neighbourTime});
}
}
}
}
return count;
}
struct producer{
int id,profit,expense;
};
void solve()
{
int n;
cin>>n;
vector<int>v(n);
for(int i=0;i<n;i++){
cin>>v[i];
}
int mini = INT_MAX;
int gate = 0;
for(int i=1;i<=n;i++){
int start = 0,end = 1e9,ans = 1e9;
while(start<=end){
ll mid = (start+end)/2;
if((mid*n)+i-1>=v[i-1]){
ans = mid;
end = mid-1;
}
else start = mid+1;
}
if((ans*n)+i-1<mini){
mini = i+(ans*n);
gate = i;
}
}
cout<<gate<<endl;
}
int main() {
#ifndef ONLINE_JUDGE
freopen("input.txt","r",stdin);
freopen("Error.txt","w",stderr);
freopen("output.txt","w",stdout);
#endif
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int t;
t = 1;
while(t--)
{
solve();
}
return 0;
}
561. Array Partition I | 1374. Generate a String With Characters That Have Odd Counts |
1822. Sign of the Product of an Array | 1464. Maximum Product of Two Elements in an Array |
1323. Maximum 69 Number | 832. Flipping an Image |
1295. Find Numbers with Even Number of Digits | 1704. Determine if String Halves Are Alike |
1732. Find the Highest Altitude | 709. To Lower Case |
1688. Count of Matches in Tournament | 1684. Count the Number of Consistent Strings |
1588. Sum of All Odd Length Subarrays | 1662. Check If Two String Arrays are Equivalent |
1832. Check if the Sentence Is Pangram | 1678. Goal Parser Interpretation |
1389. Create Target Array in the Given Order | 1313. Decompress Run-Length Encoded List |
1281. Subtract the Product and Sum of Digits of an Integer | 1342. Number of Steps to Reduce a Number to Zero |
1528. Shuffle String | 1365. How Many Numbers Are Smaller Than the Current Number |
771. Jewels and Stones | 1512. Number of Good Pairs |
672. Richest Customer Wealth | 1470. Shuffle the Array |
1431. Kids With the Greatest Number of Candies | 1480. Running Sum of 1d Array |
682. Baseball Game | 496. Next Greater Element I |