#include <bits/stdc++.h>
using namespace std;
const int inf = 2e9;
int n, m, a[403];
int memo[403][403][403];
long long ans;
int rec(int l, int r, int k) {
  if (l == r) {
    return 0;
  }
  if (k == 0) {
    return (a[r] - a[l]);
  }
  if (memo[l][r][k] != inf) {
    return memo[l][r][k];
  }
  int lo = l, hi = r - 1;
  while (lo < hi) {
    int mid = (lo + hi) / 2;
    if ((rec(l, mid, k - 1) - (a[r] - a[mid])) < 0) {
      lo = mid + 1;
    } else {
      hi = mid;
    }
  }
  memo[l][r][k] = max(rec(l, lo, k - 1), a[r] - a[lo]);
  if (lo > l) {
    memo[l][r][k] =
        min(memo[l][r][k], max(rec(l, lo - 1, k - 1), a[r] - a[lo - 1]));
  }
  return memo[l][r][k];
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cin >> n >> m;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  for (int i = 0; i < 403; ++i) {
    for (int j = 0; j < 403; ++j) {
      for (int k = 0; k < 403; ++k) {
        memo[i][j][k] = inf;
      }
    }
  }
  for (int i = 0; i < m; ++i) {
    int s, f, c, r;
    cin >> s >> f >> c >> r;
    --s, --f;
    ans = max(ans, 1LL * c * rec(s, f, r));
  }
  cout << ans;
}
