#include <bits/stdc++.h>
using namespace std;
int dp[405][405][405];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  int n, m;
  cin >> n >> m;
  int a[n + 1];
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int i = 1; i <= n; i++) {
    for (int j = i + 1; j <= n; j++) {
      dp[i][j][0] = a[j] - a[i];
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = i + 1; j <= n; j++) {
      for (int k = 1; k <= n; k++) {
        dp[i][j][k] = (int)(2e9);
        for (int l = j; l >= i; l--) {
          dp[i][j][k] = min(dp[i][j][k], max(dp[i][l][k - 1], a[j] - a[l]));
          if (dp[i][l][k - 1] < a[j] - a[l]) break;
        }
      }
    }
  }
  long long int ans = 0;
  for (int i = 0; i < m; i++) {
    int s, f, c, r;
    cin >> s >> f >> c >> r;
    ans = max(ans, c * 1LL * dp[s][f][r]);
  }
  cout << ans;
}
