#include <bits/stdc++.h>
using namespace std;
struct node {
  int id, x, c, r;
};
int n, m, a[410], f[410][410];
long long ans;
vector<node> v[410];
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
  }
  for (int i = 0; i < m; i++) {
    int x, y, c, r;
    scanf("%d%d%d%d", &x, &y, &c, &r);
    v[x].push_back((node){i, y, c, r});
  }
  for (int l = 1; l <= n; l++) {
    for (int i = 0; i <= n; i++) {
      f[l][i] = 0;
    }
    for (int i = l + 1; i <= n; i++) {
      f[i][0] = a[i] - a[l];
      for (int j = 1, k = l; j <= n; j++) {
        while (k < i - 1 && max(f[k][j - 1], a[i] - a[k]) >=
                                max(f[k + 1][j - 1], a[i] - a[k + 1])) {
          k++;
        }
        f[i][j] = max(f[k][j - 1], a[i] - a[k]);
      }
    }
    for (int i = 0; i < v[l].size(); i++) {
      ans = max(ans, 1LL * f[v[l][i].x][v[l][i].r] * v[l][i].c);
    }
  }
  cout << ans << endl;
  return 0;
}
