#include <bits/stdc++.h>
using namespace std;
const int N = 4e2 + 2;
const int M = 1e3 + 5;
const int Mod = 998244353;
int dp[N][N][N];
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int n, m;
  cin >> n >> m;
  vector<int> a(n);
  for (int& i : a) cin >> i;
  for (int j = n - 1; j >= 0; j--)
    for (int i = j - 1; i >= 0; i--) {
      dp[i][j][0] = a[j] - a[i];
      for (int k = 1, best = j; k <= n; k++) {
        while (best - 1 >= i) {
          int next = max(a[best - 1] - a[i], dp[best - 1][j][k - 1]);
          int cur = max(a[best] - a[i], dp[best][j][k - 1]);
          if (next < cur)
            best--;
          else
            break;
        }
        dp[i][j][k] = max(a[best] - a[i], dp[best][j][k - 1]);
      }
    }
  long long ans = 0;
  while (m--) {
    int s, f, c, r;
    cin >> s >> f >> c >> r;
    s--;
    f--;
    ans = max(ans, (long long)dp[s][f][r] * c);
  }
  cout << ans << endl;
  return 0;
}
