#include <bits/stdc++.h>
using namespace std;
const int maxint = -1u >> 1;
const int inf = 0x3f3f3f3f;
void print_bin(int n, unsigned long long x);
const int maxn = 4e6 + 10;
int a[maxn];
long long vis[maxn];
int n;
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i], a[i] -= i, a[i] += 2e5 + 10;
  for (int i = 1; i <= n; i++) {
    if (a[i] >= 0) vis[a[i]] += a[i] + i - 2e5 - 10;
  }
  long long ans = -1;
  for (int i = 0; i < 4e6 + 10; i++) {
    ans = max(ans, vis[i]);
  }
  cout << ans << endl;
  return 0;
}
void print_bin(int n, unsigned long long x) {
  stack<int> S;
  while (x) {
    S.push(x % 2);
    x >>= 1;
  }
  if (n < S.size()) {
    printf("binary string more than %d bits, enlarge n, try again.\n", n);
    return;
  }
  for (int i = S.size(); i < n; i++) {
    printf("0");
  }
  while (S.size()) {
    printf("%d", S.top());
    S.pop();
  }
  printf("\n");
}
